Created
December 19, 2023 16:19
-
-
Save vilenarios/9a7ae0ee7d616fe4c4147c14fa9014ee to your computer and use it in GitHub Desktop.
Verify a Turbo Receipt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static async verifyReceipt( | |
dependencies: Pick<Arbundles, "stringToBuffer" | "getCryptoDriver" | "deepHash">, | |
receipt: UploadReceiptData, | |
): Promise<boolean> { | |
const { id, deadlineHeight, timestamp, public: pubKey, signature, version } = receipt; | |
const dh = await dependencies.deepHash([ | |
dependencies.stringToBuffer("Bundlr"), | |
dependencies.stringToBuffer(version), | |
dependencies.stringToBuffer(id), | |
dependencies.stringToBuffer(deadlineHeight.toString()), | |
dependencies.stringToBuffer(timestamp.toString()), | |
]); | |
return await dependencies.getCryptoDriver().verify(pubKey, dh, base64url.toBuffer(signature)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment