generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete adding secp256r1 test vectors
Signed-off-by: Frank Hinek <[email protected]>
- Loading branch information
1 parent
64120f0
commit 4464e53
Showing
9 changed files
with
330 additions
and
187 deletions.
There are no files selected for viewing
This file contains 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
19 changes: 19 additions & 0 deletions
19
packages/crypto/tests/fixtures/test-vectors/secp256r1/bytes-to-private-key.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"description" : "Secp256k1 bytesToPrivateKey test vectors", | ||
"vectors" : [ | ||
{ | ||
"description" : "converts RFC6979 vector 1 to the expected private key", | ||
"input" : { | ||
"privateKeyBytes": "c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721" | ||
}, | ||
"output": { | ||
"crv" : "P-256", | ||
"d" : "ya-p2EW6dRZrXCFXZ7HWk05Qw9s26JsSe4piKxIPZyE", | ||
"kid" : "DOvxvJiAdIqVWIkFt5hDtCunXLF0BV4-JGv4f-ALSm0", | ||
"kty" : "EC", | ||
"x" : "YP7UuiVanTHJYet0xjVtaMBJuJI7Yfps5mliLmDyn7Y", | ||
"y": "eQP-EAi4vJmkGunpVii8ZPLxsgwtfp9Rd6PClNRGIpk" | ||
} | ||
} | ||
] | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/crypto/tests/fixtures/test-vectors/secp256r1/bytes-to-public-key.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"description" : "Secp256r1 bytesToPublicKey test vectors", | ||
"vectors" : [ | ||
{ | ||
"description" : "converts wycheproof vector 1 to the expected public key", | ||
"input" : { | ||
"publicKeyBytes": "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e" | ||
}, | ||
"output": { | ||
"crv" : "P-256", | ||
"kid" : "UB0bE6ogZhikgZQC5i4LIZIpUDDiJ6AnzpDOzOEwJiA", | ||
"kty" : "EC", | ||
"x" : "KSexBRK64-3c_kZ4KBKLrSkDJpkZ9whgacjE32xzKDg", | ||
"y": "x3h5ZOqsAOWSH7FJimD0YGdms9loUAFVjRqXTnNBUT4" | ||
} | ||
}, | ||
{ | ||
"description" : "converts wycheproof vector 2 to the expected public key", | ||
"input" : { | ||
"publicKeyBytes": "040ad99500288d466940031d72a9f5445a4d43784640855bf0a69874d2de5fe103c5011e6ef2c42dcd50d5d3d29f99ae6eba2c80c9244f4c5422f0979ff0c3ba5e" | ||
}, | ||
"output": { | ||
"crv" : "P-256", | ||
"kid" : "rC40rZh4ODQ5Y3RKw0dLQBXkVQbkEpCHEoNyFzeSIMU", | ||
"kty" : "EC", | ||
"x" : "CtmVACiNRmlAAx1yqfVEWk1DeEZAhVvwpph00t5f4QM", | ||
"y": "xQEebvLELc1Q1dPSn5mubrosgMkkT0xUIvCXn_DDul4" | ||
} | ||
}, | ||
{ | ||
"description" : "converts wycheproof vector 3 to the expected public key", | ||
"input" : { | ||
"publicKeyBytes": "04ab05fd9d0de26b9ce6f4819652d9fc69193d0aa398f0fba8013e09c58220455419235271228c786759095d12b75af0692dd4103f19f6a8c32f49435a1e9b8d45" | ||
}, | ||
"output": { | ||
"crv" : "P-256", | ||
"kid" : "UnGLajygjRCFie0aEyUb9y6Ec_ZohzbqY7sggZGL6Tk", | ||
"kty" : "EC", | ||
"x" : "qwX9nQ3ia5zm9IGWUtn8aRk9CqOY8PuoAT4JxYIgRVQ", | ||
"y": "GSNScSKMeGdZCV0St1rwaS3UED8Z9qjDL0lDWh6bjUU" | ||
} | ||
} | ||
] | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/crypto/tests/fixtures/test-vectors/secp256r1/get-curve-points.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"description" : "Secp256k1 getCurvePoints test vectors", | ||
"vectors" : [ | ||
{ | ||
"description" : "returns public key x and y coordinates given a public key", | ||
"input" : { | ||
"keyBytes": "048b542fa180e78bc981e6671374a64413e0323b439d06870dc49cb56e97775d96a0e469310d10a8ff2cb253a08d46fd845ae330e3ac4e41d0d0a85fbeb8e15795" | ||
}, | ||
"output": { | ||
"x": "8b542fa180e78bc981e6671374a64413e0323b439d06870dc49cb56e97775d96", | ||
"y": "a0e469310d10a8ff2cb253a08d46fd845ae330e3ac4e41d0d0a85fbeb8e15795" | ||
} | ||
}, | ||
{ | ||
"description" : "returns public key x and y coordinates given a private key", | ||
"input" : { | ||
"keyBytes": "08169cf81812f2e288a1131de246ebdf29b020c7625a98d098296a30a876d35a" | ||
}, | ||
"output": { | ||
"x": "25f61964e7797e36d9c369b752f53e33033c473e6db4697d74950095a1bfbe49", | ||
"y": "9c2077c6252c520501e365868a22e3a8a8106bf7be95096394d9095c55239366" | ||
} | ||
} | ||
] | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/crypto/tests/fixtures/test-vectors/secp256r1/private-key-to-bytes.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"description" : "Secp256k1 bytesToPrivateKey test vectors", | ||
"vectors" : [ | ||
{ | ||
"description" : "converts RFC6979 vector 1 to the expected private key", | ||
"input" : { | ||
"privateKey": { | ||
"crv" : "P-256", | ||
"d" : "ya-p2EW6dRZrXCFXZ7HWk05Qw9s26JsSe4piKxIPZyE", | ||
"kid" : "DOvxvJiAdIqVWIkFt5hDtCunXLF0BV4-JGv4f-ALSm0", | ||
"kty" : "EC", | ||
"x" : "YP7UuiVanTHJYet0xjVtaMBJuJI7Yfps5mliLmDyn7Y", | ||
"y": "eQP-EAi4vJmkGunpVii8ZPLxsgwtfp9Rd6PClNRGIpk" | ||
} | ||
}, | ||
"output": "c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721" | ||
} | ||
] | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/crypto/tests/fixtures/test-vectors/secp256r1/public-key-to-bytes.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"description" : "Secp256r1 bytesToPublicKey test vectors", | ||
"vectors" : [ | ||
{ | ||
"description" : "converts wycheproof vector 1 to the expected public key", | ||
"input" : { | ||
"publicKey": { | ||
"crv" : "P-256", | ||
"kid" : "UB0bE6ogZhikgZQC5i4LIZIpUDDiJ6AnzpDOzOEwJiA", | ||
"kty" : "EC", | ||
"x" : "KSexBRK64-3c_kZ4KBKLrSkDJpkZ9whgacjE32xzKDg", | ||
"y": "x3h5ZOqsAOWSH7FJimD0YGdms9loUAFVjRqXTnNBUT4" | ||
} | ||
}, | ||
"output": "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e" | ||
}, | ||
{ | ||
"description" : "converts wycheproof vector 2 to the expected public key", | ||
"input" : { | ||
"publicKey": { | ||
"crv" : "P-256", | ||
"kid" : "rC40rZh4ODQ5Y3RKw0dLQBXkVQbkEpCHEoNyFzeSIMU", | ||
"kty" : "EC", | ||
"x" : "CtmVACiNRmlAAx1yqfVEWk1DeEZAhVvwpph00t5f4QM", | ||
"y": "xQEebvLELc1Q1dPSn5mubrosgMkkT0xUIvCXn_DDul4" | ||
} | ||
}, | ||
"output": "040ad99500288d466940031d72a9f5445a4d43784640855bf0a69874d2de5fe103c5011e6ef2c42dcd50d5d3d29f99ae6eba2c80c9244f4c5422f0979ff0c3ba5e" | ||
}, | ||
{ | ||
"description" : "converts wycheproof vector 3 to the expected public key", | ||
"input" : { | ||
"publicKey": { | ||
"crv" : "P-256", | ||
"kid" : "UnGLajygjRCFie0aEyUb9y6Ec_ZohzbqY7sggZGL6Tk", | ||
"kty" : "EC", | ||
"x" : "qwX9nQ3ia5zm9IGWUtn8aRk9CqOY8PuoAT4JxYIgRVQ", | ||
"y": "GSNScSKMeGdZCV0St1rwaS3UED8Z9qjDL0lDWh6bjUU" | ||
} | ||
}, | ||
"output": "04ab05fd9d0de26b9ce6f4819652d9fc69193d0aa398f0fba8013e09c58220455419235271228c786759095d12b75af0692dd4103f19f6a8c32f49435a1e9b8d45" | ||
} | ||
] | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/crypto/tests/fixtures/test-vectors/secp256r1/validate-private-key.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"description" : "Secp256r1 validatePrivateKey test vectors", | ||
"vectors" : [ | ||
{ | ||
"description" : "returns true for valid private keys", | ||
"input" : { | ||
"privateKeyBytes": "08169cf81812f2e288a1131de246ebdf29b020c7625a98d098296a30a876d35a" | ||
}, | ||
"output": true | ||
}, | ||
{ | ||
"description" : "returns false for invalid private keys", | ||
"input" : { | ||
"privateKeyBytes": "02fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f" | ||
}, | ||
"output": false | ||
}, | ||
{ | ||
"description" : "returns false if a compressed public key is given", | ||
"input" : { | ||
"privateKeyBytes": "02ca156301f628b64ef0ccff5aba2f78f29bc865fc1da35f1b4e8f3726f1f2d987" | ||
}, | ||
"output": false | ||
}, | ||
{ | ||
"description" : "returns false if an uncompressed public key is given", | ||
"input" : { | ||
"privateKeyBytes": "048b542fa180e78bc981e6671374a64413e0323b439d06870dc49cb56e97775d96a0e469310d10a8ff2cb253a08d46fd845ae330e3ac4e41d0d0a85fbeb8e15795" | ||
}, | ||
"output": false | ||
} | ||
] | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/crypto/tests/fixtures/test-vectors/secp256r1/validate-public-key.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"description" : "Secp256r1 validatePublicKey test vectors", | ||
"vectors" : [ | ||
{ | ||
"description" : "returns true for valid compressed public keys", | ||
"input" : { | ||
"publicKeyBytes": "02ca156301f628b64ef0ccff5aba2f78f29bc865fc1da35f1b4e8f3726f1f2d987" | ||
}, | ||
"output": true | ||
}, | ||
{ | ||
"description" : "returns true for valid uncompressed public keys", | ||
"input" : { | ||
"publicKeyBytes": "048b542fa180e78bc981e6671374a64413e0323b439d06870dc49cb56e97775d96a0e469310d10a8ff2cb253a08d46fd845ae330e3ac4e41d0d0a85fbeb8e15795" | ||
}, | ||
"output": true | ||
}, | ||
{ | ||
"description" : "returns false for invalid public keys", | ||
"input" : { | ||
"publicKeyBytes": "02fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f" | ||
}, | ||
"output": false | ||
}, | ||
{ | ||
"description" : "returns false if a private key is given", | ||
"input" : { | ||
"publicKeyBytes": "08169cf81812f2e288a1131de246ebdf29b020c7625a98d098296a30a876d35a" | ||
}, | ||
"output": false | ||
} | ||
] | ||
} |
Oops, something went wrong.