@@ -23,7 +23,7 @@ describe("canonical CLAS proof envelope", () => {
2323 assert . equal ( proof . canonicalization , "json.sorted_keys.v1" ) ;
2424 assert . equal ( proof . hash . alg , "SHA-256" ) ;
2525 assert . ok ( proof . hash . value ) ;
26- assert . equal ( proof . signature . alg , "ed25519 " ) ;
26+ assert . equal ( proof . signature . alg , "Ed25519 " ) ;
2727 assert . ok ( proof . signature . value ) ;
2828 assert . equal ( proof . signature . kid , "testKid" ) ;
2929
@@ -34,6 +34,38 @@ describe("canonical CLAS proof envelope", () => {
3434 assert . equal ( isSignedCommandLayerReceipt ( signed ) , true ) ;
3535 } ) ;
3636
37+
38+
39+ test ( "verifies canonical Ed25519 algorithm without caller normalization" , ( ) => {
40+ const signed = signCommandLayerReceipt ( baseReceipt , { privateKeyPem : kp . privateKeyPem , kid : "testKid" } ) ;
41+ const proof = signed . metadata ! . proof ! ;
42+
43+ const canonical = verifyCommandLayerReceipt (
44+ { ...signed , metadata : { ...signed . metadata ! , proof : { ...proof , signature : { ...proof . signature , alg : "Ed25519" } } } } ,
45+ { publicKeyPemOrDer : kp . publicKeyPem }
46+ ) ;
47+ assert . equal ( canonical . ok , true ) ;
48+
49+ const legacy = verifyCommandLayerReceipt (
50+ { ...signed , metadata : { ...signed . metadata ! , proof : { ...proof , signature : { ...proof . signature , alg : "ed25519" } } } } ,
51+ { publicKeyPemOrDer : kp . publicKeyPem }
52+ ) ;
53+ assert . equal ( legacy . ok , true ) ;
54+ } ) ;
55+
56+ test ( "fails on unsupported signature algorithms" , ( ) => {
57+ const signed = signCommandLayerReceipt ( baseReceipt , { privateKeyPem : kp . privateKeyPem , kid : "testKid" } ) ;
58+ const proof = signed . metadata ! . proof ! ;
59+
60+ const bad = verifyCommandLayerReceipt (
61+ { ...signed , metadata : { ...signed . metadata ! , proof : { ...proof , signature : { ...proof . signature , alg : "rsa" as never } } } } ,
62+ { publicKeyPemOrDer : kp . publicKeyPem }
63+ ) ;
64+
65+ assert . equal ( bad . status , "INVALID" ) ;
66+ assert . ok ( bad . errors . includes ( "ERR_UNSUPPORTED_SIGNATURE_ALG" ) ) ;
67+ } ) ;
68+
3769 test ( "requires signature.kid to be a non-empty string" , ( ) => {
3870 const signed = signCommandLayerReceipt ( baseReceipt , { privateKeyPem : kp . privateKeyPem , kid : "testKid" } ) ;
3971 const p = signed . metadata ! . proof ! ;
0 commit comments