@canton-network/core-signing-lib 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/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # signing-lib
2
+
3
+ This library provides:
4
+
5
+ - The OpenRPC typing and controller code generated from [api-specs/openrpc-signing-api.json](../../api-specs/openrpc-signing-api.json)
6
+ - A standard `interface` for signing drivers to implement:
7
+
8
+ ```typescript
9
+ export interface SigningDriverInterface {
10
+ partyMode: PartyMode
11
+ signingProvider: SigningProvider
12
+ controller: (authContext: AuthContext | undefined) => Methods
13
+ }
14
+ ```
15
+
16
+ The `controller` function should be an implementation of `buildController` from [./src/rpc-gen/index.ts](./src/rpc-gen/index.ts) which takes an optional `AuthContext`.
17
+
18
+ To see a simple example of a signing driver, see [core/singing-internal](../signing-internal).
19
+
20
+ ### Important Note
21
+
22
+ Other than the optional `internalTxId` parameter in `signTransaction`, ALL instances of `txId` refer to the TransactionID given by the **signing provider**, not the Wallet Kernel.
23
+
24
+ While some signing providers allow an external transaction to be stored with the transaction, this _cannot_ be relied upon, therefore in order to lookup specific transactions, the Wallet Kernel must store and use the transaction ID given by the signing provider (which is returned by the `signTransaction` method).
@@ -0,0 +1,29 @@
1
+ import { AuthContext } from '@canton-network/core-wallet-auth';
2
+ import { Methods } from './rpc-gen/index.js';
3
+ import { Error as RpcError } from './rpc-gen/typings.js';
4
+ export { default as buildController, Methods } from './rpc-gen/index.js';
5
+ export * from './rpc-gen/typings.js';
6
+ export declare const CC_COIN_TYPE = 6767;
7
+ export declare function isRpcError<T>(value: T | RpcError): value is RpcError;
8
+ export declare enum PartyMode {
9
+ INTERNAL = "internal",
10
+ EXTERNAL = "external"
11
+ }
12
+ export interface KeyPair {
13
+ publicKey: string;
14
+ privateKey: string;
15
+ }
16
+ export declare enum SigningProvider {
17
+ WALLET_KERNEL = "wallet-kernel",
18
+ PARTICIPANT = "participant",
19
+ FIREBLOCKS = "fireblocks"
20
+ }
21
+ export interface SigningDriverInterface {
22
+ partyMode: PartyMode;
23
+ signingProvider: SigningProvider;
24
+ controller: (userId: AuthContext['userId'] | undefined) => Methods;
25
+ }
26
+ export declare const signTransactionHash: (txHash: string, privateKey: string) => string;
27
+ export declare const getPublicKeyFromPrivate: (privateKey: string) => string;
28
+ export declare const createKeyPair: () => KeyPair;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAIxD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACxE,cAAc,sBAAsB,CAAA;AAEpC,eAAO,MAAM,YAAY,OAAO,CAAA;AAEhC,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,QAAQ,GAAG,KAAK,IAAI,QAAQ,CAEpE;AAED,oBAAY,SAAS;IACjB,QAAQ,aAAa;IACrB,QAAQ,aAAa;CACxB;AAED,MAAM,WAAW,OAAO;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;CACrB;AAED,oBAAY,eAAe;IACvB,aAAa,kBAAkB;IAC/B,WAAW,gBAAgB;IAC3B,UAAU,eAAe;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACnC,SAAS,EAAE,SAAS,CAAA;IACpB,eAAe,EAAE,eAAe,CAAA;IAChC,UAAU,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,SAAS,KAAK,OAAO,CAAA;CACrE;AAED,eAAO,MAAM,mBAAmB,GAC5B,QAAQ,MAAM,EACd,YAAY,MAAM,KACnB,MAMF,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,YAAY,MAAM,KAAG,MAK5D,CAAA;AAED,eAAO,MAAM,aAAa,QAAO,OAMhC,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,35 @@
1
+ import nacl from 'tweetnacl';
2
+ import naclUtil from 'tweetnacl-util';
3
+ export { default as buildController } from './rpc-gen/index.js';
4
+ export * from './rpc-gen/typings.js';
5
+ export const CC_COIN_TYPE = 6767;
6
+ export function isRpcError(value) {
7
+ return value.error_description !== undefined;
8
+ }
9
+ export var PartyMode;
10
+ (function (PartyMode) {
11
+ PartyMode["INTERNAL"] = "internal";
12
+ PartyMode["EXTERNAL"] = "external";
13
+ })(PartyMode || (PartyMode = {}));
14
+ export var SigningProvider;
15
+ (function (SigningProvider) {
16
+ SigningProvider["WALLET_KERNEL"] = "wallet-kernel";
17
+ SigningProvider["PARTICIPANT"] = "participant";
18
+ SigningProvider["FIREBLOCKS"] = "fireblocks";
19
+ })(SigningProvider || (SigningProvider = {}));
20
+ export const signTransactionHash = (txHash, privateKey) => {
21
+ const decodedKey = naclUtil.decodeBase64(privateKey);
22
+ return naclUtil.encodeBase64(nacl.sign.detached(naclUtil.decodeBase64(txHash), decodedKey));
23
+ };
24
+ export const getPublicKeyFromPrivate = (privateKey) => {
25
+ const secretKey = naclUtil.decodeBase64(privateKey);
26
+ // The public key is the last 32 bytes of the secretKey for Ed25519
27
+ const publicKey = secretKey.slice(32);
28
+ return naclUtil.encodeBase64(publicKey);
29
+ };
30
+ export const createKeyPair = () => {
31
+ const key = nacl.sign.keyPair();
32
+ const publicKey = naclUtil.encodeBase64(key.publicKey);
33
+ const privateKey = naclUtil.encodeBase64(key.secretKey);
34
+ return { publicKey, privateKey };
35
+ };
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@canton-network/core-signing-lib",
3
+ "version": "0.1.0",
4
+ "packageManager": "yarn@4.9.2",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc -b",
10
+ "clean": "tsc -b --clean && rm -rf ./dist"
11
+ },
12
+ "dependencies": {
13
+ "@canton-network/core-wallet-auth": "^0.1.0",
14
+ "fs-extra": "^11.3.0",
15
+ "lodash": "^4.17.21",
16
+ "tweetnacl": "^1.0.3",
17
+ "tweetnacl-util": "^0.15.1"
18
+ },
19
+ "devDependencies": {
20
+ "@types/fs-extra": "^11",
21
+ "@types/lodash": "^4.17.17",
22
+ "@types/node": "^22.15.29",
23
+ "typescript": "^5.8.3"
24
+ },
25
+ "files": [
26
+ "dist/*"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public"
30
+ }
31
+ }