@nuggetslife/vc-rn 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +31 -0
- package/android/build.gradle +101 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/nuggetslife/bindings/vc/vc.kt +673 -0
- package/android/src/main/java/com/nuggetslife/vc/VcModule.kt +30 -0
- package/android/src/main/java/com/nuggetslife/vc/VcPackage.kt +17 -0
- package/android/src/main/jniLibs/arm64-v8a/libvc.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libvc.so +0 -0
- package/android/src/main/jniLibs/x86/libvc.so +0 -0
- package/android/src/main/jniLibs/x86_64/libvc.so +0 -0
- package/ios/Vc-Bridging-Header.h +2 -0
- package/ios/VcModule.mm +14 -0
- package/ios/VcModule.swift +23 -0
- package/ios/vc.swift +446 -0
- package/ios/vc.xcframework/Info.plist +48 -0
- package/ios/vc.xcframework/ios-arm64/Headers/module.modulemap +6 -0
- package/ios/vc.xcframework/ios-arm64/Headers/vcFFI.h +174 -0
- package/ios/vc.xcframework/ios-arm64/libvc.a +0 -0
- package/ios/vc.xcframework/ios-arm64_x86_64-simulator/Headers/module.modulemap +6 -0
- package/ios/vc.xcframework/ios-arm64_x86_64-simulator/Headers/vcFFI.h +174 -0
- package/ios/vc.xcframework/ios-arm64_x86_64-simulator/libvc.a +0 -0
- package/ios/vcFFI.h +174 -0
- package/lib/commonjs/Bls12381G2KeyPair.js +405 -0
- package/lib/commonjs/Bls12381G2KeyPair.js.map +1 -0
- package/lib/commonjs/index.d.js +18 -0
- package/lib/commonjs/index.d.js.map +1 -0
- package/lib/commonjs/index.js +20 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/types/BlsCurveName.js +14 -0
- package/lib/commonjs/types/BlsCurveName.js.map +1 -0
- package/lib/commonjs/types/GenerateKeyPairOptions.js +2 -0
- package/lib/commonjs/types/GenerateKeyPairOptions.js.map +1 -0
- package/lib/commonjs/types/JsonWebKey.js +2 -0
- package/lib/commonjs/types/JsonWebKey.js.map +1 -0
- package/lib/commonjs/types/JwkKeyPairOptions.js +6 -0
- package/lib/commonjs/types/JwkKeyPairOptions.js.map +1 -0
- package/lib/commonjs/types/JwkKty.js +13 -0
- package/lib/commonjs/types/JwkKty.js.map +1 -0
- package/lib/commonjs/types/KeyPairOptions.js +2 -0
- package/lib/commonjs/types/KeyPairOptions.js.map +1 -0
- package/lib/commonjs/types/KeyPairSigner.js +2 -0
- package/lib/commonjs/types/KeyPairSigner.js.map +1 -0
- package/lib/commonjs/types/KeyPairVerifier.js +2 -0
- package/lib/commonjs/types/KeyPairVerifier.js.map +1 -0
- package/lib/commonjs/types/index.js +20 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/utils/codec.js +22 -0
- package/lib/commonjs/utils/codec.js.map +1 -0
- package/lib/commonjs/utils/index.js +19 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/commonjs/validators/Bls12381G2Jwk.js +19 -0
- package/lib/commonjs/validators/Bls12381G2Jwk.js.map +1 -0
- package/lib/commonjs/validators/JsonWebKey.js +27 -0
- package/lib/commonjs/validators/JsonWebKey.js.map +1 -0
- package/lib/module/Bls12381G2KeyPair.js +398 -0
- package/lib/module/Bls12381G2KeyPair.js.map +1 -0
- package/lib/module/index.d.js +9 -0
- package/lib/module/index.d.js.map +1 -0
- package/lib/module/index.js +14 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types/BlsCurveName.js +8 -0
- package/lib/module/types/BlsCurveName.js.map +1 -0
- package/lib/module/types/GenerateKeyPairOptions.js +2 -0
- package/lib/module/types/GenerateKeyPairOptions.js.map +1 -0
- package/lib/module/types/JsonWebKey.js +2 -0
- package/lib/module/types/JsonWebKey.js.map +1 -0
- package/lib/module/types/JwkKeyPairOptions.js +2 -0
- package/lib/module/types/JwkKeyPairOptions.js.map +1 -0
- package/lib/module/types/JwkKty.js +7 -0
- package/lib/module/types/JwkKty.js.map +1 -0
- package/lib/module/types/KeyPairOptions.js +2 -0
- package/lib/module/types/KeyPairOptions.js.map +1 -0
- package/lib/module/types/KeyPairSigner.js +2 -0
- package/lib/module/types/KeyPairSigner.js.map +1 -0
- package/lib/module/types/KeyPairVerifier.js +2 -0
- package/lib/module/types/KeyPairVerifier.js.map +1 -0
- package/lib/module/types/index.js +3 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/utils/codec.js +13 -0
- package/lib/module/utils/codec.js.map +1 -0
- package/lib/module/utils/index.js +2 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/module/validators/Bls12381G2Jwk.js +11 -0
- package/lib/module/validators/Bls12381G2Jwk.js.map +1 -0
- package/lib/module/validators/JsonWebKey.js +19 -0
- package/lib/module/validators/JsonWebKey.js.map +1 -0
- package/lib/typescript/src/Bls12381G2KeyPair.d.ts +104 -0
- package/lib/typescript/src/Bls12381G2KeyPair.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types/BlsCurveName.d.ts +7 -0
- package/lib/typescript/src/types/BlsCurveName.d.ts.map +1 -0
- package/lib/typescript/src/types/GenerateKeyPairOptions.d.ts +18 -0
- package/lib/typescript/src/types/GenerateKeyPairOptions.d.ts.map +1 -0
- package/lib/typescript/src/types/JsonWebKey.d.ts +60 -0
- package/lib/typescript/src/types/JsonWebKey.d.ts.map +1 -0
- package/lib/typescript/src/types/JwkKeyPairOptions.d.ts +23 -0
- package/lib/typescript/src/types/JwkKeyPairOptions.d.ts.map +1 -0
- package/lib/typescript/src/types/JwkKty.d.ts +6 -0
- package/lib/typescript/src/types/JwkKty.d.ts.map +1 -0
- package/lib/typescript/src/types/KeyPairOptions.d.ts +22 -0
- package/lib/typescript/src/types/KeyPairOptions.d.ts.map +1 -0
- package/lib/typescript/src/types/KeyPairSigner.d.ts +7 -0
- package/lib/typescript/src/types/KeyPairSigner.d.ts.map +1 -0
- package/lib/typescript/src/types/KeyPairVerifier.d.ts +8 -0
- package/lib/typescript/src/types/KeyPairVerifier.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +9 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/codec.d.ts +3 -0
- package/lib/typescript/src/utils/codec.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +2 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/validators/Bls12381G2Jwk.d.ts +4 -0
- package/lib/typescript/src/validators/Bls12381G2Jwk.d.ts.map +1 -0
- package/lib/typescript/src/validators/JsonWebKey.d.ts +4 -0
- package/lib/typescript/src/validators/JsonWebKey.d.ts.map +1 -0
- package/nuggetslife-vc.podspec +42 -0
- package/package.json +164 -0
- package/src/Bls12381G2KeyPair.ts +447 -0
- package/src/index.d.ts +126 -0
- package/src/index.tsx +22 -0
- package/src/types/BlsCurveName.ts +6 -0
- package/src/types/GenerateKeyPairOptions.ts +17 -0
- package/src/types/JsonWebKey.ts +68 -0
- package/src/types/JwkKeyPairOptions.ts +24 -0
- package/src/types/JwkKty.ts +5 -0
- package/src/types/KeyPairOptions.ts +21 -0
- package/src/types/KeyPairSigner.ts +6 -0
- package/src/types/KeyPairVerifier.ts +8 -0
- package/src/types/index.ts +8 -0
- package/src/utils/codec.ts +12 -0
- package/src/utils/index.ts +1 -0
- package/src/validators/Bls12381G2Jwk.ts +21 -0
- package/src/validators/JsonWebKey.ts +28 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for constructing a key pair
|
|
3
|
+
*/
|
|
4
|
+
export interface KeyPairOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The key id
|
|
7
|
+
*/
|
|
8
|
+
readonly id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The key controller
|
|
11
|
+
*/
|
|
12
|
+
readonly controller?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Base58 encoding of the private key
|
|
15
|
+
*/
|
|
16
|
+
readonly privateKeyBase58?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Base58 encoding of the public key
|
|
19
|
+
*/
|
|
20
|
+
readonly publicKeyBase58: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BlsCurveName } from "./BlsCurveName";
|
|
2
|
+
export type { GenerateKeyPairOptions } from "./GenerateKeyPairOptions";
|
|
3
|
+
export type { JsonWebKey } from "./JsonWebKey";
|
|
4
|
+
export { JwkKty } from "./JwkKty";
|
|
5
|
+
export type { JwkKeyPairOptions } from "./JwkKeyPairOptions";
|
|
6
|
+
export type { KeyPairOptions } from "./KeyPairOptions";
|
|
7
|
+
export type { KeyPairSigner } from "./KeyPairSigner";
|
|
8
|
+
export type { KeyPairVerifier } from "./KeyPairVerifier";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { base64url } from "rfc4648";
|
|
2
|
+
import bs58 from "bs58";
|
|
3
|
+
|
|
4
|
+
export const convertBase64urlToBase58 = (value: string): string => {
|
|
5
|
+
return bs58.encode(base64url.parse(value, { loose: true }));
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function uint8ArrayToHexString(arr: Uint8Array) {
|
|
9
|
+
return Array.prototype.map.call(arr, function(byte) {
|
|
10
|
+
return ('0' + (byte & 0xFF).toString(16)).slice(-2);
|
|
11
|
+
}).join('');
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { convertBase64urlToBase58, uint8ArrayToHexString } from "./codec";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { assertPrivateBlsJwk, assertPublicBlsJwk } from "./JsonWebKey";
|
|
2
|
+
import { BlsCurveName } from "../types";
|
|
3
|
+
import type { JsonWebKey } from "../types";
|
|
4
|
+
|
|
5
|
+
export const assertBls12381G2PublicJwk = (jwk: JsonWebKey): boolean => {
|
|
6
|
+
// Returns false because the BLS12-381 G2 x coordinate is not the proper length
|
|
7
|
+
return (
|
|
8
|
+
assertPublicBlsJwk(jwk) &&
|
|
9
|
+
(jwk.crv === BlsCurveName.DEPRECATED_G2 || jwk.crv === BlsCurveName.G2) &&
|
|
10
|
+
jwk.x.length === 128
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const assertBls12381G2PrivateJwk = (jwk: JsonWebKey): boolean => {
|
|
15
|
+
// Returns false because the BLS12-381 G2 x coordinate is not the proper length
|
|
16
|
+
return (
|
|
17
|
+
assertPrivateBlsJwk(jwk) &&
|
|
18
|
+
(jwk.crv === BlsCurveName.DEPRECATED_G2 || jwk.crv === BlsCurveName.G2) &&
|
|
19
|
+
jwk.x.length === 128
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BlsCurveName, JwkKty } from "../types";
|
|
2
|
+
import type { JsonWebKey } from "../types";
|
|
3
|
+
|
|
4
|
+
const checkCommonBlsJwkValues = (jwk: JsonWebKey): boolean => {
|
|
5
|
+
const allowedCurveNames: string[] = [
|
|
6
|
+
BlsCurveName.G1,
|
|
7
|
+
BlsCurveName.G2,
|
|
8
|
+
BlsCurveName.DEPRECATED_G1,
|
|
9
|
+
BlsCurveName.DEPRECATED_G2
|
|
10
|
+
];
|
|
11
|
+
return (
|
|
12
|
+
// A BLS key type MUST be set to "EC" or "OKP"
|
|
13
|
+
typeof jwk !== "undefined" &&
|
|
14
|
+
(jwk.kty === JwkKty.EC || jwk.kty === JwkKty.OctetKeyPair) &&
|
|
15
|
+
// The curve property should indicate either one of the types listed on allowedCurveNames
|
|
16
|
+
allowedCurveNames.indexOf(jwk.crv) >= 0
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const assertPublicBlsJwk = (jwk: JsonWebKey): boolean => {
|
|
21
|
+
// Performs common checks, but also checks to make sure a d value is not included
|
|
22
|
+
// If a d value is included then this is a private key not a public key
|
|
23
|
+
return checkCommonBlsJwkValues(jwk) && typeof jwk.d === "undefined";
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const assertPrivateBlsJwk = (jwk: JsonWebKey): boolean => {
|
|
27
|
+
return checkCommonBlsJwkValues(jwk);
|
|
28
|
+
};
|