1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use crate::prelude::*;
pub use holochain_deterministic_integrity::ed25519::*;
pub fn sign<K, D>(key: K, data: D) -> ExternResult<Signature>
where
K: Into<AgentPubKey>,
D: serde::Serialize + std::fmt::Debug,
{
HDK.with(|h| {
h.borrow()
.sign(Sign::new(key.into(), data).map_err(|e| wasm_error!(e.into()))?)
})
}
pub fn sign_raw<K>(key: K, data: Vec<u8>) -> ExternResult<Signature>
where
K: Into<AgentPubKey>,
{
HDK.with(|h| h.borrow().sign(Sign::new_raw(key.into(), data)))
}
pub fn sign_ephemeral<D>(datas: Vec<D>) -> ExternResult<EphemeralSignatures>
where
D: serde::Serialize + std::fmt::Debug,
{
HDK.with(|h| {
h.borrow()
.sign_ephemeral(SignEphemeral::new(datas).map_err(|e| wasm_error!(e.into()))?)
})
}
pub fn sign_ephemeral_raw(datas: Vec<Vec<u8>>) -> ExternResult<EphemeralSignatures> {
HDK.with(|h| h.borrow().sign_ephemeral(SignEphemeral::new_raw(datas)))
}