diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 16a2dc30..2a46f460 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,15 +2,21 @@ ## [Unreleased] +### Added + +- feat: management canister interface updates for schnorr signatures + +### Changed +- feat: replaces hdkey and bip32 implementations with `@scure/bip39` and `@scure/bip32` due to vulnerability and lack of maintenance for `elliptic` +- chore: bumps dev dependency versions to remove warnings +- chore: addresses eslint errors uncovered by bumping eslint version + ## [2.0.0] - 2024-07-16 ### Changed - ci: removing headless browser tests pending a rewrite - ci: changing token for creating release -- feat: replaces hdkey and bip32 implementations with `@scure/bip39` and `@scure/bip32` due to vulnerability and lack of maintenance for `elliptic` -- chore: bumps dev dependency versions to remove warnings -- chore: addresses eslint errors uncovered by bumping eslint version ### Added diff --git a/packages/agent/src/canisters/management.did b/packages/agent/src/canisters/management.did index cf8ae065..d3acb2af 100644 --- a/packages/agent/src/canisters/management.did +++ b/packages/agent/src/canisters/management.did @@ -76,6 +76,11 @@ type ecdsa_curve = variant { secp256k1; }; +type schnorr_algorithm = variant { + bip340secp256k1; + ed25519; +}; + type satoshi = nat64; type bitcoin_network = variant { @@ -281,6 +286,27 @@ type sign_with_ecdsa_result = record { signature : blob; }; +type schnorr_public_key_args = record { + canister_id : opt canister_id; + derivation_path : vec blob; + key_id : record { algorithm : schnorr_algorithm; name : text }; +}; + +type schnorr_public_key_result = record { + public_key : blob; + chain_code : blob; +}; + +type sign_with_schnorr_args = record { + message : blob; + derivation_path : vec blob; + key_id : record { algorithm : schnorr_algorithm; name : text }; +}; + +type sign_with_schnorr_result = record { + signature : blob; +}; + type node_metrics_history_args = record { subnet_id : principal; start_at_timestamp_nanos : nat64; @@ -353,6 +379,10 @@ service ic : { ecdsa_public_key : (ecdsa_public_key_args) -> (ecdsa_public_key_result); sign_with_ecdsa : (sign_with_ecdsa_args) -> (sign_with_ecdsa_result); + // Threshold Schnorr signature + schnorr_public_key : (schnorr_public_key_args) -> (schnorr_public_key_result); + sign_with_schnorr : (sign_with_schnorr_args) -> (sign_with_schnorr_result); + // bitcoin interface bitcoin_get_balance : (bitcoin_get_balance_args) -> (bitcoin_get_balance_result); diff --git a/packages/agent/src/canisters/management_idl.ts b/packages/agent/src/canisters/management_idl.ts index 72fd4d41..07f15d1d 100644 --- a/packages/agent/src/canisters/management_idl.ts +++ b/packages/agent/src/canisters/management_idl.ts @@ -250,6 +250,22 @@ export default ({ IDL }) => { amount: IDL.Nat, }); const raw_rand_result = IDL.Vec(IDL.Nat8); + const schnorr_algorithm = IDL.Variant({ + ed25519: IDL.Null, + bip340secp256k1: IDL.Null, + }); + const schnorr_public_key_args = IDL.Record({ + key_id: IDL.Record({ + algorithm: schnorr_algorithm, + name: IDL.Text, + }), + canister_id: IDL.Opt(canister_id), + derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), + }); + const schnorr_public_key_result = IDL.Record({ + public_key: IDL.Vec(IDL.Nat8), + chain_code: IDL.Vec(IDL.Nat8), + }); const sign_with_ecdsa_args = IDL.Record({ key_id: IDL.Record({ name: IDL.Text, curve: ecdsa_curve }), derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), @@ -258,6 +274,17 @@ export default ({ IDL }) => { const sign_with_ecdsa_result = IDL.Record({ signature: IDL.Vec(IDL.Nat8), }); + const sign_with_schnorr_args = IDL.Record({ + key_id: IDL.Record({ + algorithm: schnorr_algorithm, + name: IDL.Text, + }), + derivation_path: IDL.Vec(IDL.Vec(IDL.Nat8)), + message: IDL.Vec(IDL.Nat8), + }); + const sign_with_schnorr_result = IDL.Record({ + signature: IDL.Vec(IDL.Nat8), + }); const start_canister_args = IDL.Record({ canister_id: canister_id }); const stop_canister_args = IDL.Record({ canister_id: canister_id }); const stored_chunks_args = IDL.Record({ canister_id: canister_id }); @@ -308,7 +335,9 @@ export default ({ IDL }) => { ), provisional_top_up_canister: IDL.Func([provisional_top_up_canister_args], [], []), raw_rand: IDL.Func([], [raw_rand_result], []), + schnorr_public_key: IDL.Func([schnorr_public_key_args], [schnorr_public_key_result], []), sign_with_ecdsa: IDL.Func([sign_with_ecdsa_args], [sign_with_ecdsa_result], []), + sign_with_schnorr: IDL.Func([sign_with_schnorr_args], [sign_with_schnorr_result], []), start_canister: IDL.Func([start_canister_args], [], []), stop_canister: IDL.Func([stop_canister_args], [], []), stored_chunks: IDL.Func([stored_chunks_args], [stored_chunks_result], []), diff --git a/packages/agent/src/canisters/management_service.ts b/packages/agent/src/canisters/management_service.ts index dbbc5c8b..fa4ed243 100644 --- a/packages/agent/src/canisters/management_service.ts +++ b/packages/agent/src/canisters/management_service.ts @@ -230,6 +230,16 @@ export interface provisional_top_up_canister_args { } export type raw_rand_result = Uint8Array | number[]; export type satoshi = bigint; +export type schnorr_algorithm = { ed25519: null } | { bip340secp256k1: null }; +export interface schnorr_public_key_args { + key_id: { algorithm: schnorr_algorithm; name: string }; + canister_id: [] | [canister_id]; + derivation_path: Array; +} +export interface schnorr_public_key_result { + public_key: Uint8Array | number[]; + chain_code: Uint8Array | number[]; +} export interface sign_with_ecdsa_args { key_id: { name: string; curve: ecdsa_curve }; derivation_path: Array; @@ -238,6 +248,14 @@ export interface sign_with_ecdsa_args { export interface sign_with_ecdsa_result { signature: Uint8Array | number[]; } +export interface sign_with_schnorr_args { + key_id: { algorithm: schnorr_algorithm; name: string }; + derivation_path: Array; + message: Uint8Array | number[]; +} +export interface sign_with_schnorr_result { + signature: Uint8Array | number[]; +} export interface start_canister_args { canister_id: canister_id; } @@ -294,7 +312,9 @@ export default interface _SERVICE { >; provisional_top_up_canister: ActorMethod<[provisional_top_up_canister_args], undefined>; raw_rand: ActorMethod<[], raw_rand_result>; + schnorr_public_key: ActorMethod<[schnorr_public_key_args], schnorr_public_key_result>; sign_with_ecdsa: ActorMethod<[sign_with_ecdsa_args], sign_with_ecdsa_result>; + sign_with_schnorr: ActorMethod<[sign_with_schnorr_args], sign_with_schnorr_result>; start_canister: ActorMethod<[start_canister_args], undefined>; stop_canister: ActorMethod<[stop_canister_args], undefined>; stored_chunks: ActorMethod<[stored_chunks_args], stored_chunks_result>;