@dfns/dfns-key-import-bundler
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -216,3 +216,3 @@ let wasm; | ||
* | ||
* Takes as input the `secret_key` to be imported, `signers_info` (contains information | ||
* Takes as input the `secret_scalar` to be imported, `signers_info` (contains information | ||
* about the _n_ key holders, needs to be retrieved from Dfns API) | ||
@@ -231,3 +231,3 @@ * `min_signers` (which will be the threshold and has to satisfy _2 ≤ min_signers ≤ n_), | ||
* Throws `Error` in case of failure | ||
* @param {SecretKey} secret_key | ||
* @param {SecretScalar} secret_scalar | ||
* @param {SignersInfo} signers_info | ||
@@ -239,8 +239,8 @@ * @param {number} min_signers | ||
*/ | ||
export function buildKeyImportRequest(secret_key, signers_info, min_signers, protocol, curve) { | ||
export function buildKeyImportRequest(secret_scalar, signers_info, min_signers, protocol, curve) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
_assertClass(secret_key, SecretKey); | ||
_assertClass(secret_scalar, SecretScalar); | ||
_assertClass(signers_info, SignersInfo); | ||
wasm.buildKeyImportRequest(retptr, secret_key.__wbg_ptr, signers_info.__wbg_ptr, min_signers, protocol, curve); | ||
wasm.buildKeyImportRequest(retptr, secret_scalar.__wbg_ptr, signers_info.__wbg_ptr, min_signers, protocol, curve); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
@@ -302,9 +302,14 @@ var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
/** | ||
* Secret key to be imported | ||
* Secret key (represented by a scalar) to be imported | ||
* | ||
* Our library only works with secret keys represented by a scalar. It's the case for ECDSA | ||
* and Schnorr signing schemes. However, it is not the case for EdDSA. If you need to import | ||
* an EdDSA secret key, you first need to convert it into the scalar by using | ||
* [`convert_eddsa_secret_key_to_scalar`] function. | ||
*/ | ||
export class SecretKey { | ||
export class SecretScalar { | ||
static __wrap(ptr) { | ||
ptr = ptr >>> 0; | ||
const obj = Object.create(SecretKey.prototype); | ||
const obj = Object.create(SecretScalar.prototype); | ||
obj.__wbg_ptr = ptr; | ||
@@ -324,27 +329,14 @@ | ||
const ptr = this.__destroy_into_raw(); | ||
wasm.__wbg_secretkey_free(ptr); | ||
wasm.__wbg_secretscalar_free(ptr); | ||
} | ||
/** | ||
* Parses the secret key in big-endian format (the most widely-used format) | ||
* | ||
* Throws `Error` if secret key is invalid | ||
* @param {Uint8Array} bytes | ||
* @returns {SecretKey} | ||
* @returns {SecretScalar} | ||
*/ | ||
static fromBytesBE(bytes) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.secretkey_fromBytesBE(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return SecretKey.__wrap(r0); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
} | ||
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.secretscalar_fromBytesBE(ptr0, len0); | ||
return SecretScalar.__wrap(ret); | ||
} | ||
@@ -437,2 +429,12 @@ } | ||
export function __wbindgen_number_new(arg0) { | ||
const ret = arg0; | ||
return addHeapObject(ret); | ||
}; | ||
export function __wbindgen_string_new(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
export function __wbindgen_jsval_loose_eq(arg0, arg1) { | ||
@@ -456,5 +458,8 @@ const ret = getObject(arg0) == getObject(arg1); | ||
export function __wbindgen_number_new(arg0) { | ||
const ret = arg0; | ||
return addHeapObject(ret); | ||
export function __wbg_String_4370c5505c674d30(arg0, arg1) { | ||
const ret = String(getObject(arg1)); | ||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
@@ -467,7 +472,2 @@ | ||
export function __wbindgen_string_new(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
export function __wbg_getwithrefkey_d1f0d12f1f1b63ea(arg0, arg1) { | ||
@@ -482,10 +482,2 @@ const ret = getObject(arg0)[getObject(arg1)]; | ||
export function __wbg_String_4370c5505c674d30(arg0, arg1) { | ||
const ret = String(getObject(arg1)); | ||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
export function __wbg_crypto_c48a774b022d20ac(arg0) { | ||
@@ -492,0 +484,0 @@ const ret = getObject(arg0).crypto; |
@@ -6,3 +6,3 @@ /* tslint:disable */ | ||
* | ||
* Takes as input the `secret_key` to be imported, `signers_info` (contains information | ||
* Takes as input the `secret_scalar` to be imported, `signers_info` (contains information | ||
* about the _n_ key holders, needs to be retrieved from Dfns API) | ||
@@ -21,3 +21,3 @@ * `min_signers` (which will be the threshold and has to satisfy _2 ≤ min_signers ≤ n_), | ||
* Throws `Error` in case of failure | ||
* @param {SecretKey} secret_key | ||
* @param {SecretScalar} secret_scalar | ||
* @param {SignersInfo} signers_info | ||
@@ -29,3 +29,3 @@ * @param {number} min_signers | ||
*/ | ||
export function buildKeyImportRequest(secret_key: SecretKey, signers_info: SignersInfo, min_signers: number, protocol: number, curve: number): any; | ||
export function buildKeyImportRequest(secret_scalar: SecretScalar, signers_info: SignersInfo, min_signers: number, protocol: number, curve: number): any; | ||
/** | ||
@@ -70,14 +70,17 @@ * The protocol for which a key can be used. | ||
/** | ||
* Secret key to be imported | ||
* Secret key (represented by a scalar) to be imported | ||
* | ||
* Our library only works with secret keys represented by a scalar. It's the case for ECDSA | ||
* and Schnorr signing schemes. However, it is not the case for EdDSA. If you need to import | ||
* an EdDSA secret key, you first need to convert it into the scalar by using | ||
* [`convert_eddsa_secret_key_to_scalar`] function. | ||
*/ | ||
export class SecretKey { | ||
export class SecretScalar { | ||
free(): void; | ||
/** | ||
* Parses the secret key in big-endian format (the most widely-used format) | ||
* | ||
* Throws `Error` if secret key is invalid | ||
* @param {Uint8Array} bytes | ||
* @returns {SecretKey} | ||
* @returns {SecretScalar} | ||
*/ | ||
static fromBytesBE(bytes: Uint8Array): SecretKey; | ||
static fromBytesBE(bytes: Uint8Array): SecretScalar; | ||
} | ||
@@ -84,0 +87,0 @@ /** |
@@ -5,3 +5,3 @@ { | ||
"description": "Cryptography code for importing a key to Dfns", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"license": "MIT OR Apache-2.0", | ||
@@ -8,0 +8,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
331584
687