ic_cdk/api/management_canister/schnorr/mod.rs
1//! Threshold Schnorr signing API.
2
3use crate::api::call::{call, call_with_payment128, CallResult};
4use candid::Principal;
5
6mod types;
7pub use types::*;
8
9// Source: https://internetcomputer.org/docs/current/references/t-sigs-how-it-works/#fees-for-the-t-schnorr-production-key
10const SIGN_WITH_SCHNORR_FEE: u128 = 26_153_846_153;
11
12/// Return a SEC1 encoded Schnorr public key for the given canister using the given derivation path.
13///
14/// See [IC method `schnorr_public_key`](https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-schnorr_public_key).
15pub async fn schnorr_public_key(
16 arg: SchnorrPublicKeyArgument,
17) -> CallResult<(SchnorrPublicKeyResponse,)> {
18 call(
19 Principal::management_canister(),
20 "schnorr_public_key",
21 (arg,),
22 )
23 .await
24}
25
26/// Return a new Schnorr signature of the given message that can be separately verified against a derived Schnorr public key.
27///
28/// See [IC method `sign_with_schnorr`](https://internetcomputer.org/docs/current/references/ic-interface-spec/#ic-sign_with_schnorr).
29///
30/// This call requires cycles payment.
31/// This method handles the cycles cost under the hood.
32/// Check [Threshold signatures](https://internetcomputer.org/docs/current/references/t-sigs-how-it-works) for more details.
33pub async fn sign_with_schnorr(
34 arg: SignWithSchnorrArgument,
35) -> CallResult<(SignWithSchnorrResponse,)> {
36 call_with_payment128(
37 Principal::management_canister(),
38 "sign_with_schnorr",
39 (arg,),
40 SIGN_WITH_SCHNORR_FEE,
41 )
42 .await
43}