Skip to content

Commit

Permalink
chore(MPC-2011): update to TSM ver 68.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MnrGreg committed Dec 13, 2024
1 parent 602f75e commit dd701dd
Show file tree
Hide file tree
Showing 13 changed files with 495 additions and 35 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockdaemon/buildervault-web3-provider",
"version": "0.0.2",
"version": "0.0.3",
"description": "EIP-1193 Compatible Ethereum provider for BuilderVault",
"repository": {
"type": "git",
Expand Down Expand Up @@ -35,7 +35,7 @@
"web3": "^4.1.2"
},
"dependencies": {
"@sepior/tsmsdkv2": "^65.0.0",
"@sepior/tsmsdkv2": "^68.0.0",
"asn1.js": "^5.4.1",
"crypto": "^1.0.1",
"debug": "^4.3.7",
Expand Down
5 changes: 4 additions & 1 deletion src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ export class BuildervaultWeb3Provider extends HttpProvider {
await playerConfig.withAPIKeyAuthentication((this.config as { [key: string]: any })[playerApiKeyConfigKey]);
} else if (playerClientCertConfigKey in this.config && playerClientKeyConfigKey in this.config && playerMTLSpublicKeyConfigKey in this.config) {
const cert = new crypto.X509Certificate((this.config as { [key: string]: any })[playerMTLSpublicKeyConfigKey]);

await playerConfig.withPublicKeyPinning(cert.publicKey.export({type: "spki",format: "der"}));

await playerConfig.withMTLSAuthentication(
(this.config as { [key: string]: any })[playerClientKeyConfigKey],
(this.config as { [key: string]: any })[playerClientCertConfigKey],
cert.publicKey.export({ type: "spki", format: "der" })
false, "", "", ""
);
} else {
throw new Error(`player${i} authentication credentials are required`);
Expand Down
120 changes: 120 additions & 0 deletions types/api_aes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
export class API_AES {
/**
* Create a new AES instance, used internally
* @param {TSMClient} tsmClient
*/
constructor(tsmClient: TSMClient, _sdkv2: any);
clientHandle: any;
sdkv2: any;
/**
* Generate a new key in the TSM
* @param {SessionConfig} sessionConfig
* @param {Number} threshold
* @param {Number} keyLength
* @param {string} desiredKeyID
* @return {Promise<string>} KeyID
*/
generateKey(sessionConfig: SessionConfig, threshold: number, keyLength: number, desiredKeyID?: string): Promise<string>;
/**
* Export AES key shares from the TSM
* @param {SessionConfig} sessionConfig
* @param {String} keyID
* @param {Uint8Array} wrappingKey
* @return {Promise<{"wrappedKeyShare": Uint8Array, "checksum": Uint8Array}>}
*/
exportKeyShare(sessionConfig: SessionConfig, keyID: string, wrappingKey: Uint8Array): Promise<{
"wrappedKeyShare": Uint8Array;
"checksum": Uint8Array;
}>;
/**
* Import AES key shares into the TSM
* @param {SessionConfig} sessionConfig
* @param {Number} threshold
* @param {Uint8Array} wrappedKeyShare
* @param {Uint8Array} checksum
* @param {String} desiredKeyID
* @return {Promise<String>} KeyID
*/
importKeyShare(sessionConfig: SessionConfig, threshold: number, wrappedKeyShare: Uint8Array, checksum: Uint8Array, desiredKeyID: string): Promise<string>;
/**
* Create an AES CTR key stream
* @param {SessionConfig} sessionConfig
* @param {String} keyID
* @param {Uint8Array} iv
* @param {Number} keyStreamLength
* @return {Promise<Uint8Array>}
*/
ctrKeyStream(sessionConfig: SessionConfig, keyID: string, iv: Uint8Array, keyStreamLength: number): Promise<Uint8Array>;
/**
* AES CBC encrypt
* @param {SessionConfig} sessionConfig
* @param {String} keyID
* @param {Uint8Array} iv
* @param {Uint8Array} plaintext
* @return {Promise<Uint8Array>}
*/
cbcEncrypt(sessionConfig: SessionConfig, keyID: string, iv: Uint8Array, plaintext: Uint8Array): Promise<Uint8Array>;
/**
* AES CBC Decrypt
* @param {SessionConfig} sessionConfig
* @param {String} keyID
* @param {Uint8Array} iv
* @param {Uint8Array} ciphertext
* @return {Promise<Uint8Array>}
*/
cbcDecrypt(sessionConfig: SessionConfig, keyID: string, iv: Uint8Array, ciphertext: Uint8Array): Promise<Uint8Array>;
/**
* AES GCM Encrypt
* @param {SessionConfig} sessionConfig
* @param {String} keyID
* @param {Uint8Array} iv
* @param {Uint8Array} plaintext
* @param {Uint8Array} additionalData
* @return {Promise<Uint8Array>}
*/
gcmEncrypt(sessionConfig: SessionConfig, keyID: string, iv: Uint8Array, plaintext: Uint8Array, additionalData: Uint8Array): Promise<Uint8Array>;
/**
* AES GCM Decrypt
* @param {SessionConfig} sessionConfig
* @param {String} keyID
* @param {Uint8Array} iv
* @param {Uint8Array} ciphertext
* @param {Uint8Array} additionalData
* @param {Uint8Array} tag
* @return {Promise<Uint8Array>}
*/
gcmDecrypt(sessionConfig: SessionConfig, keyID: string, iv: Uint8Array, ciphertext: Uint8Array, additionalData: Uint8Array, tag: Uint8Array): Promise<Uint8Array>;
/**
* AES Finalize CTR
* @param {Uint8Array[]} partialResults
* @return {Promise<Uint8Array>}
*/
finalizeCTR(partialResults: Uint8Array[]): Promise<Uint8Array>;
/**
* AES Finalize CBC Encryption
* @param {Uint8Array[]} partialResults
* @return {Promise<Uint8Array>}
*/
finalizeCBCEncrypt(partialResults: Uint8Array[]): Promise<Uint8Array>;
/**
* AES Finalize CBC Decryption
* @param {Uint8Array[]} partialResults
* @return {Promise<Uint8Array>}
*/
finalizeCBCDecrypt(partialResults: Uint8Array[]): Promise<Uint8Array>;
/**
* AES Finalize GCM Encryption
* @param {Uint8Array[]} partialResults
* @return {Promise<{ciphertext: Uint8Array, authTag: Uint8Array}>}
*/
finalizeGCMEncrypt(partialResults: Uint8Array[]): Promise<{
ciphertext: Uint8Array;
authTag: Uint8Array;
}>;
/**
* AES Finalize GCM Decryption
* @param {Uint8Array[]} partialResults
* @return {Promise<Uint8Array>}
*/
finalizeGCMDecrypt(partialResults: Uint8Array[]): Promise<Uint8Array>;
}
20 changes: 10 additions & 10 deletions types/api_ecdsa.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class API_ECDSA {
export class API_ECDSA {
/**
* Create a new ECDSA instance, used internally
* @param {TSMClient} tsmClient
Expand All @@ -23,15 +23,6 @@
* @return {Promise<string[]>}
*/
generatePresignatures(sessionConfig: SessionConfig, keyID: string, presignatureCount: number): Promise<string[]>;
/**
* Sign a message
* @param {SessionConfig} sessionConfig
* @param {string} keyID
* @param {Uint32Array} derivationPath
* @param {Uint8Array} message
* @return {Promise<Uint8Array>}
*/
sign(sessionConfig: SessionConfig, keyID: string, derivationPath: Uint32Array, message: Uint8Array): Promise<Uint8Array>;
/**
* Use an existing presignature to create a partial signature
* @param {string} keyID
Expand All @@ -44,6 +35,15 @@
"partialSignature": Uint8Array;
"presignatureID": string;
}>;
/**
* Create a partial signature
* @param {SessionConfig} sessionConfig
* @param {string} keyID
* @param {Uint32Array} derivationPath
* @param {Uint8Array} message
* @return {Promise<Uint8Array>}
*/
sign(sessionConfig: SessionConfig, keyID: string, derivationPath: Uint32Array, message: Uint8Array): Promise<Uint8Array>;
/**
* Generate partial recovery data used to recover private key in case of emergency
* @param {SessionConfig} sessionConfig
Expand Down
61 changes: 61 additions & 0 deletions types/api_hmac.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
export class API_HMAC {
/**
* Create a new AES instance, used internally
* @param {TSMClient} tsmClient
*/
constructor(tsmClient: TSMClient, _sdkv2: any);
clientHandle: any;
sdkv2: any;
/**
* Generate a new key in the TSM
* @param {SessionConfig} sessionConfig
* @param {Number} threshold
* @param {Number} keyLength
* @param {string} desiredKeyID
* @return {Promise<string>} KeyID
*/
generateKey(sessionConfig: SessionConfig, threshold: number, keyLength: number, desiredKeyID?: string): Promise<string>;
/**
* Export HMAC key shares from the TSM
* @param {SessionConfig} sessionConfig
* @param {String} keyID
* @param {Uint8Array} wrappingKey
* @return {Promise<{"wrappedKeyShare": Uint8Array, "checksum": Uint8Array}>}
*/
exportKeyShare(sessionConfig: SessionConfig, keyID: string, wrappingKey: Uint8Array): Promise<{
"wrappedKeyShare": Uint8Array;
"checksum": Uint8Array;
}>;
/**
* Import key shares into the TSM
* @param {SessionConfig} sessionConfig
* @param {Number} threshold
* @param {Uint8Array} wrappedKeyShare
* @param {Uint8Array} checksum
* @param {String} desiredKeyID
* @return {Promise<String>} KeyID
*/
importKeyShare(sessionConfig: SessionConfig, threshold: number, wrappedKeyShare: Uint8Array, checksum: Uint8Array, desiredKeyID: string): Promise<string>;
/**
* Create a HMAC SHA256
* @param {SessionConfig} sessionConfig
* @param {String} keyID
* @param {Uint8Array} data
* @return {Promise<Uint8Array>} Partial Result
*/
hmacSHA256(sessionConfig: SessionConfig, keyID: string, data: Uint8Array): Promise<Uint8Array>;
/**
* Create a HMAC SHA512
* @param {SessionConfig} sessionConfig
* @param {String} keyID
* @param {Uint8Array} data
* @return {Promise<Uint8Array>} Partial Result
*/
hmacSHA512(sessionConfig: SessionConfig, keyID: string, data: Uint8Array): Promise<Uint8Array>;
/**
* HMAC Finalize
* @param {Uint8Array[]} partialResults
* @return {Promise<Uint8Array>}
*/
finalizeHMAC(partialResults: Uint8Array[]): Promise<Uint8Array>;
}
Loading

0 comments on commit dd701dd

Please sign in to comment.