@@ -957,7 +957,7 @@ export declare namespace validate {
957957 * Supports `secp256k1`, `p256`, and `webAuthn` signature types.
958958 *
959959 * :::warning
960- * `keychain` signatures are not supported and will return `false` .
960+ * `keychain` signatures are not supported and will throw an error .
961961 * :::
962962 *
963963 * @example
@@ -1068,44 +1068,42 @@ export function verify(
10681068 } ) ( )
10691069 if ( ! address ) return false
10701070
1071- try {
1072- const envelope = from ( signature )
1073-
1074- if ( envelope . type === 'secp256k1' ) {
1075- if ( ! address ) return false
1076- return ox_Secp256k1 . verify ( {
1077- address,
1078- payload,
1079- signature : envelope . signature ,
1080- } )
1081- }
1071+ const envelope = from ( signature )
10821072
1083- if ( envelope . type === 'p256' ) {
1084- const envelopeAddress = Address . fromPublicKey ( envelope . publicKey )
1085- if ( ! Address . isEqual ( envelopeAddress , address ) ) return false
1086- return ox_P256 . verify ( {
1087- hash : envelope . prehash ,
1088- publicKey : envelope . publicKey ,
1089- payload,
1090- signature : envelope . signature ,
1091- } )
1092- }
1073+ if ( envelope . type === 'secp256k1' ) {
1074+ if ( ! address ) return false
1075+ return ox_Secp256k1 . verify ( {
1076+ address,
1077+ payload,
1078+ signature : envelope . signature ,
1079+ } )
1080+ }
10931081
1094- if ( envelope . type === 'webAuthn ' ) {
1095- const envelopeAddress = Address . fromPublicKey ( envelope . publicKey )
1096- if ( ! Address . isEqual ( envelopeAddress , address ) ) return false
1097- return ox_WebAuthnP256 . verify ( {
1098- challenge : Hex . from ( payload ) ,
1099- metadata : envelope . metadata ,
1100- publicKey : envelope . publicKey ,
1101- signature : envelope . signature ,
1102- } )
1103- }
1082+ if ( envelope . type === 'p256 ' ) {
1083+ const envelopeAddress = Address . fromPublicKey ( envelope . publicKey )
1084+ if ( ! Address . isEqual ( envelopeAddress , address ) ) return false
1085+ return ox_P256 . verify ( {
1086+ hash : envelope . prehash ,
1087+ publicKey : envelope . publicKey ,
1088+ payload ,
1089+ signature : envelope . signature ,
1090+ } )
1091+ }
11041092
1105- return false
1106- } catch {
1107- return false
1093+ if ( envelope . type === 'webAuthn' ) {
1094+ const envelopeAddress = Address . fromPublicKey ( envelope . publicKey )
1095+ if ( ! Address . isEqual ( envelopeAddress , address ) ) return false
1096+ return ox_WebAuthnP256 . verify ( {
1097+ challenge : Hex . from ( payload ) ,
1098+ metadata : envelope . metadata ,
1099+ publicKey : envelope . publicKey ,
1100+ signature : envelope . signature ,
1101+ } )
11081102 }
1103+
1104+ throw new VerificationError (
1105+ `Unable to verify signature envelope of type "${ envelope . type } ".` ,
1106+ )
11091107}
11101108
11111109export declare namespace verify {
@@ -1173,3 +1171,10 @@ export class InvalidSerializedError extends Errors.BaseError {
11731171 } )
11741172 }
11751173}
1174+
1175+ /**
1176+ * Error thrown when a signature envelope fails to verify.
1177+ */
1178+ export class VerificationError extends Errors . BaseError {
1179+ override readonly name = 'SignatureEnvelope.VerificationError'
1180+ }
0 commit comments