Skip to content

Commit

Permalink
feat: adds support for Bls12381G1KeyPairs
Browse files Browse the repository at this point in the history
This adds support for Bls12381G1 KeyPairs, but the signer factory
and verifier factories which use @mattrglobal/bbs-signatures still
need to be updated before sign and verify will work properly.

re: issue #15

Signed-off-by: Kyle Den Hartog <[email protected]>
  • Loading branch information
kdenhartog-mattr committed Sep 9, 2020
1 parent 3e11f99 commit e3a758a
Show file tree
Hide file tree
Showing 8 changed files with 1,058 additions and 3 deletions.
480 changes: 480 additions & 0 deletions __tests__/Bls12381G1KeyPair.spec.ts

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions __tests__/__fixtures__/exampleBls12381G1JwkKeyPair.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "did:example:489398593#test",
"controller": "did:example:489398593",
"publicKeyJwk": {
"kid": "did:example:489398593#test",
"kty": "EC",
"crv": "BLS12381_G1",
"x": "tCgCNuUYQotPEsrljWi-lIRIPpzhqsnJV1NPnE7je6glUb-FJm9IYkuv2hbHw22i"
},
"privateKeyJwk": {
"kid": "did:example:489398593#test",
"kty": "EC",
"crv": "BLS12381_G1",
"x": "tCgCNuUYQotPEsrljWi-lIRIPpzhqsnJV1NPnE7je6glUb-FJm9IYkuv2hbHw22i",
"d": "TXNvJBBG3h23H5hFJcnRZmYd_j1TqpwtJOllYGU3yyw"
}
}
6 changes: 6 additions & 0 deletions __tests__/__fixtures__/exampleBls12381G1KeyPair.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "did:example:489398593#test",
"controller": "did:example:489398593",
"publicKeyBase58": "7cJGQwV5XyzUjJEzY5doVhv62Qqou6qW7G4eh9YbUywgyeDCobiXjN8CnQ7wpWBrGR",
"privateKeyBase58": "6DLV2ijYvG7Dh45sP7V9GfprG7sB26GYaJnSuFQX6cD1"
}
12 changes: 12 additions & 0 deletions __tests__/__fixtures__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,43 @@
* limitations under the License.
*/

import exampleBls12381G1JwkKeyPair from "./exampleBls12381G1JwkKeyPair.json";
import exampleBls12381G1KeyPair from "./exampleBls12381G1KeyPair.json";
import exampleBls12381G2JwkKeyPair from "./exampleBls12381G2JwkKeyPair.json";
import exampleBls12381G2KeyPair from "./exampleBls12381G2KeyPair.json";

const exampleSingleMessage = new Uint8Array(Buffer.from("someData"));
const exampleSingleMessageG2KeySignature =
"o6eLL+eFfvSdh+vyNCsyZxmVJTLe2DuqD93W6hG7M7se+9MdoyEdPRNiB6aM5XjVBaJQ6wSt41HTVcHTnq3aOCDAVlc27m70SJwVCUgbsqA9J/tBEqfZF7VEGs79765wIubvyed/WQR/wZGUlRSg/w==";

const exampleSingleMessageG1KeySignature =
"o6eLL+eFfvSdh+vyNCsyZxmVJTLe2DuqD93W6hG7M7se+9MdoyEdPRNiB6aM5XjVBaJQ6wSt41HTVcHTnq3aOCDAVlc27m70SJwVCUgbsqA9J/tBEqfZF7VEGs79765wIubvyed/WQR/wZGUlRSg/w==";

const exampleMultiMessage = [
new Uint8Array(Buffer.from("test")),
new Uint8Array(Buffer.from("value"))
];
const exampleMultiMessageG2KeySignature =
"gTeYNYnogNM2En/YLq7pEtDDOi1PIlVtKBevXQjIMZtk1KdOtApAw2HUNV0eFG5mXhD28X0tmXbubLqwQb0K/lKxVZJvTS2MyuP1bRDnsyJB9tOE/AnpoNDWKnjjVu6tQNgG3YNQsJZhVgvHyUAo8A==";

const exampleMultiMessageG1KeySignature =
"gTeYNYnogNM2En/YLq7pEtDDOi1PIlVtKBevXQjIMZtk1KdOtApAw2HUNV0eFG5mXhD28X0tmXbubLqwQb0K/lKxVZJvTS2MyuP1bRDnsyJB9tOE/AnpoNDWKnjjVu6tQNgG3YNQsJZhVgvHyUAo8A==";

const badSignature =
"AdcLcdMzvXU6pNiQHv/9/Y5QzEQpLMAfducfqOTdt/Jc6alMUGHn972ZK9aAhJTxLYGRtnvBnsQPBPgZbW+COymHfuR9jcZhoQlnfXXminowFrWHez1H0Jp4iGkHU+OlXeePg93jQW737gJs3cv8Cg==";
const badSignatureBadLength =
"aaaaAdcLcdMzvXU6pNiQHv/9/Y5QzEQpLMAfducfqOTdt/Jc6alMUGHn972ZK9aAhJTxLYGRtnvBnsQPBPgZbW+COymHfuR9jcZhoQlnfXXminowFrWHez1H0Jp4iGkHU+OlXeePg93jQW737gJs3cv8Cg==";

export {
exampleBls12381G1JwkKeyPair,
exampleBls12381G1KeyPair,
exampleBls12381G2JwkKeyPair,
exampleBls12381G2KeyPair,
exampleSingleMessage,
exampleSingleMessageG1KeySignature,
exampleSingleMessageG2KeySignature,
exampleMultiMessage,
exampleMultiMessageG1KeySignature,
exampleMultiMessageG2KeySignature,
badSignature,
badSignatureBadLength
Expand Down
Loading

0 comments on commit e3a758a

Please sign in to comment.