Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System API for threshold ECDSA #6

Merged
merged 13 commits into from
Apr 12, 2022
12 changes: 12 additions & 0 deletions spec/ic.did
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ service ic : {
deposit_cycles : (record {canister_id : canister_id}) -> ();
raw_rand : () -> (blob);

// Threshold ECDSA signature
get_ecdsa_public_key : (record {
ninegua marked this conversation as resolved.
Show resolved Hide resolved
canister_id : opt canister_id;
derivation_path : vec blob;
key_id : text;
ninegua marked this conversation as resolved.
Show resolved Hide resolved
}) -> (record { public_key : blob; chain_code : blob; });
Dfinity-Bjoern marked this conversation as resolved.
Show resolved Hide resolved
sign_with_ecdsa : (record {
message_hash : blob;
derivation_path : vec blob;
key_id : text;
}) -> (blob);

// provisional interfaces for the pre-ledger world
provisional_create_canister_with_cycles : (record {
amount: opt nat;
Expand Down
22 changes: 22 additions & 0 deletions spec/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,28 @@ There is no restriction on who can invoke this method.

This method takes no input and returns 32 pseudo-random bytes to the caller. The return value is unknown to any part of the IC at time of the submission of this call. A new return value is generated for each call to this method.

[#ic-get_ecdsa_public_key]
=== IC method `get_ecdsa_public_key`

This method returns the threshold ECDSA public key for the given canister using the given derivation path. If the `canister_id` is unspecified, it will default to the canister id of the caller.
ninegua marked this conversation as resolved.
Show resolved Hide resolved
The `derivation_path` is a vector of variable length byte strings.
For https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki[BIP-0032] compatibility, each byte string (`blob`) must be a 4-byte big-endian encoding of an unsigned integer less than 2^31^ (non-hardened).
The only supported `key_id` value at the moment is `"secp256k1"`.
ninegua marked this conversation as resolved.
Show resolved Hide resolved

The return result also contains a `chain_code` which can be used for key derivation purpose if needed.
ninegua marked this conversation as resolved.
Show resolved Hide resolved
ninegua marked this conversation as resolved.
Show resolved Hide resolved

This call requires that the ECDSA feature is enabled and working properly, and the `canister_id` meets the requirement of a canister id.
ninegua marked this conversation as resolved.
Show resolved Hide resolved
Otherwise it will be rejected.
andreacerulli marked this conversation as resolved.
Show resolved Hide resolved

[#ic-sign_with_ecdsa]
=== IC method `sign_with_ecdsa`

This method returns a new threshold ECDSA signature of the given `message_hash` that can be separately verified against a derived ECDSA public key.
ninegua marked this conversation as resolved.
Show resolved Hide resolved
This public key can be obtained by calling `get_ecdsa_public_key` with the caller's `canister_id`, and the same `derivation_path` and `key_id` used here.

This call requires that the ECDSA feature is enabled and working properly, the caller is a canister, and `message_hash` is of 32-bytes long.
ninegua marked this conversation as resolved.
Show resolved Hide resolved
ninegua marked this conversation as resolved.
Show resolved Hide resolved
Otherwise it will be rejected.

ninegua marked this conversation as resolved.
Show resolved Hide resolved
[#ic-provisional_create_canister_with_cycles]
=== IC method `provisional_create_canister_with_cycles`

Expand Down