Skip to content

Commit

Permalink
Rename publicKey param and document params for verifyEnclaveSignature
Browse files Browse the repository at this point in the history
  • Loading branch information
r-n-o committed May 9, 2024
1 parent 7de782f commit db658ca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
9 changes: 6 additions & 3 deletions export/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,11 @@ <h2>Message log</h2>

/**
* Function to verify enclave signature on import bundle received from the server.
* @param {string} enclaveQuorumPublic uncompressed public key for the quorum key which produced the signature
* @param {string} publicSignature signature bytes encoded as a hexadecimal string
* @param {string} signedData signed bytes encoded as a hexadecimal string. This could be public key bytes directly, or JSON-encoded bytes
*/
async function verifyEnclaveSignature(enclaveQuorumPublic, publicSignature, publicKey) {
async function verifyEnclaveSignature(enclaveQuorumPublic, publicSignature, signedData) {
/** Turnkey Signer enclave's public keys */
const TURNKEY_SIGNERS_ENCLAVES = {
"prod": "04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569",
Expand All @@ -355,8 +358,8 @@ <h2>Message log</h2>

// The ECDSA signature is ASN.1 DER encoded but WebCrypto uses raw format
const publicSignatureBuf = fromDerSignature(publicSignature);
const publicKeyBuf = uint8arrayFromHexString(publicKey);
return await crypto.subtle.verify({ name: "ECDSA", namedCurve: "P-256", hash: {name: "SHA-256" }}, quorumKey, publicSignatureBuf, publicKeyBuf);
const signedDataBuf = uint8arrayFromHexString(signedData);
return await crypto.subtle.verify({ name: "ECDSA", namedCurve: "P-256", hash: {name: "SHA-256" }}, quorumKey, publicSignatureBuf, signedDataBuf);
}

/**
Expand Down
9 changes: 6 additions & 3 deletions import/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,11 @@

/**
* Function to verify enclave signature on import bundle received from the server.
* @param {string} enclaveQuorumPublic uncompressed public key for the quorum key which produced the signature
* @param {string} publicSignature signature bytes encoded as a hexadecimal string
* @param {string} signedData signed bytes encoded as a hexadecimal string. This could be public key bytes directly, or JSON-encoded bytes
*/
async function verifyEnclaveSignature(enclaveQuorumPublic, publicSignature, publicKey) {
async function verifyEnclaveSignature(enclaveQuorumPublic, publicSignature, signedData) {
/** Turnkey Signer enclave's public keys */
const TURNKEY_SIGNERS_ENCLAVES = {
"prod": "04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569",
Expand All @@ -312,8 +315,8 @@

// The ECDSA signature is ASN.1 DER encoded but WebCrypto uses raw format
const publicSignatureBuf = fromDerSignature(publicSignature);
const publicKeyBuf = uint8arrayFromHexString(publicKey);
return await crypto.subtle.verify({ name: "ECDSA", namedCurve: "P-256", hash: {name: "SHA-256" }}, quorumKey, publicSignatureBuf, publicKeyBuf);
const signedDataBuf = uint8arrayFromHexString(signedData);
return await crypto.subtle.verify({ name: "ECDSA", namedCurve: "P-256", hash: {name: "SHA-256" }}, quorumKey, publicSignatureBuf, signedDataBuf);
}

/**
Expand Down
9 changes: 6 additions & 3 deletions import/standalone.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,11 @@ <h2>Message log</h2>

/**
* Function to verify enclave signature on import bundle received from the server.
* @param {string} enclaveQuorumPublic uncompressed public key for the quorum key which produced the signature
* @param {string} publicSignature signature bytes encoded as a hexadecimal string
* @param {string} signedData signed bytes encoded as a hexadecimal string. This could be public key bytes directly, or JSON-encoded bytes
*/
async function verifyEnclaveSignature(enclaveQuorumPublic, publicSignature, publicKey) {
async function verifyEnclaveSignature(enclaveQuorumPublic, publicSignature, signedData) {
/** Turnkey Signer enclave's public keys */
const TURNKEY_SIGNERS_ENCLAVES = {
"prod": "04cf288fe433cc4e1aa0ce1632feac4ea26bf2f5a09dcfe5a42c398e06898710330f0572882f4dbdf0f5304b8fc8703acd69adca9a4bbf7f5d00d20a5e364b2569",
Expand All @@ -364,8 +367,8 @@ <h2>Message log</h2>

// The ECDSA signature is ASN.1 DER encoded but WebCrypto uses raw format
const publicSignatureBuf = fromDerSignature(publicSignature);
const publicKeyBuf = uint8arrayFromHexString(publicKey);
return await crypto.subtle.verify({ name: "ECDSA", namedCurve: "P-256", hash: {name: "SHA-256" }}, quorumKey, publicSignatureBuf, publicKeyBuf);
const signedDataBuf = uint8arrayFromHexString(signedData);
return await crypto.subtle.verify({ name: "ECDSA", namedCurve: "P-256", hash: {name: "SHA-256" }}, quorumKey, publicSignatureBuf, signedDataBuf);
}

/**
Expand Down

0 comments on commit db658ca

Please sign in to comment.