Skip to content

Commit

Permalink
feat: management canister interface schnorr update
Browse files Browse the repository at this point in the history
  • Loading branch information
krpeacock committed Aug 5, 2024
1 parent 3b4df1b commit ba8bbe2
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 30 additions & 0 deletions packages/agent/src/canisters/management.did
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ type ecdsa_curve = variant {
secp256k1;
};

type schnorr_algorithm = variant {
bip340secp256k1;
ed25519;
};

type satoshi = nat64;

type bitcoin_network = variant {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
29 changes: 29 additions & 0 deletions packages/agent/src/canisters/management_idl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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 });
Expand Down Expand Up @@ -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], []),
Expand Down
20 changes: 20 additions & 0 deletions packages/agent/src/canisters/management_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Uint8Array | number[]>;
}
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<Uint8Array | number[]>;
Expand All @@ -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<Uint8Array | number[]>;
message: Uint8Array | number[];
}
export interface sign_with_schnorr_result {
signature: Uint8Array | number[];
}
export interface start_canister_args {
canister_id: canister_id;
}
Expand Down Expand Up @@ -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>;
Expand Down

0 comments on commit ba8bbe2

Please sign in to comment.