You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ed25519KeyIdentity.verify is calling ed25519.verify with the wrong args
To Reproduce
import{Ed25519KeyIdentity}from'@dfinity/identity';// Argumentsconstargs=['vfKdMCDuw5sx85POiPwPNJ+OMp9711ORElAET0G1KpqoausXE4QUVjqalfQ7z+ZKlW/MWtHwlqHLRJVwPrR6Cg==','{"termsAndConditionsId":"default","termsAndConditionsConsent":true,"emailAddress":"[email protected]","temporaryIdentityPublicKeyDerBase64":"MCowBQYDK2VwAyEAQgA3YzGamtPWxowSoUrwtew+lha45zKXay+IycoZOwA="}','MCowBQYDK2VwAyEAQgA3YzGamtPWxowSoUrwtew+lha45zKXay+IycoZOwA=',];// Decode the signature from base64constsignature=Uint8Array.from(Buffer.from(args[0],'base64'));// Convert to Uint8Arrayconsole.log('Decoded signature length:',signature.length);// Check the length of the signature// Decode the body (JSON string)constmessage=Uint8Array.from(Buffer.from(args[1],'utf8'));// Convert to Uint8Arrayconsole.log('Decoded message length:',message.length);// Check the length of the message// Decode the public key from base64consttemporaryIdentityPublicKeyDerBase64=Uint8Array.from(Buffer.from(args[2],'base64'));// Convert to Uint8Arrayconsole.log('Decoded public key length:',temporaryIdentityPublicKeyDerBase64.length);// Check the length of the public keyconstresult=Ed25519KeyIdentity.verify(signature,message,temporaryIdentityPublicKeyDerBase64);console.log('Verification result:',result);
Output:
Decoded signature length: 64
Decoded message length: 209
Decoded public key length: 44
/test/node_modules/@noble/curves/abstract/utils.js:152
throw new Error(`${title} expected ${expectedLength} bytes, got ${len}`);
^
Error: signature expected 64 bytes, got 209
at ensureBytes (/test/node_modules/@noble/curves/abstract/utils.js:152:15)
at Object.verify (/test/node_modules/@noble/curves/abstract/edwards.js:386:42)
at Ed25519KeyIdentity.verify (/test/node_modules/@dfinity/identity/lib/cjs/identity/ed25519.js:211:34)
at file:///test/src/test.mjs:28:35
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Node.js v20.11.0
If we swap message and signature as follows, it doesn't error out anymore, but the output will be false
The problem most likely is caused by THIS LINE, where we call ed25519.verify(message, signature, publicKey), but ed25519.verify expects the signature as first arg and message as second.
Ed25519KeyIdentity.verify is calling ed25519.verify with the wrong args
To Reproduce
Output:
If we swap message and signature as follows, it doesn't error out anymore, but the output will be
false
Output:
Decoded signature length: 64 Decoded message length: 209 Decoded public key length: 44 Verification result: false
Screenshots
The problem most likely is caused by THIS LINE, where we call
ed25519.verify(message, signature, publicKey)
, but ed25519.verify expects the signature as first arg and message as second.The text was updated successfully, but these errors were encountered: