Open HenriqueNogara opened 2 years ago
Users are already able to sign data without relying on our code.
E.g. using TweetNaCl
const key = new KeyPair(KeyType.Ed25519);
const seed = bs58.decode(key.private);
let naclKeyPair = nacl.sign.keyPair.fromSeed(seed);
let challengeBytes = Uint8Array.from([1,2,3,4]);
let signature = nacl.sign(challengeBytes, naclKeyPair.secretKey);
console.log(`Signature: ${bs58.encode(signature)}`);
I do think we should switch to using UInt8Array
to represent the private/public keys though, from Base58-BTC encoded strings. This is because it's the type existing libraries like TweetNaCl expect as input and to avoid requiring developers bring in Base58 dependencies to decode the strings we return. Alternative would be to expose the dencode_b58
, decode_multibase
functions too, which might be useful for Storage
implementers regardless.
Advantages of exposing Ed25519::sign
:
KeyPair
, WasmPrivateKey
or generalised to UInt8Array
/String
.Disadvantages:
We have had requests to include other features in identity.rs
such as BIP-39 mnemonics, so I think some developers might appreciate being able to use same the functions we do internally out of convenience.
See also this comment: https://github.com/iotaledger/identity.rs/pull/597/files#r811781156
We might need the Storage trait not to be Send/Sync for other bindings (e.g Python) as well, so we should not tie its bounds to the wasm feature.
I agree. Some conditional compilation required now just for wasm
might be beneficial for other use-cases too, so we can use other features (named more specifically like storage-sync
for example) on top of target-based compilation.
Edit: as long as enabling --all-features
does not break compilation.
Verify the need to return an error on KeyDel
I think all Not the point the issue raised, it's about idempotency and consistency between Rust and bindings behaviour.Storage
functions need to be async and fallible to account for unknowable remote implementations where every little network request could fail.
This comment on #660 may have been missed regarding the Stronghold bindings package namespace: https://github.com/iotaledger/identity.rs/pull/660/files#r816770207
Edit: resolved.
As per internal discussions, the following tasks were marked as either important or easy to do prior to 0.5.0.
UInt8Array
rather than Base58-BTC encoded strings for keys in the Wasm bindings. https://github.com/iotaledger/identity.rs/issues/721Storage::key_del
should be idempotent or not. #729Account
Signature
not to contain PublicKey. https://github.com/iotaledger/identity.rs/issues/722SetPassword
method from Storage. https://github.com/iotaledger/identity.rs/issues/720Each needs its own issue or PR now.
Description
Remove exposure of Ed25519.sign, remove
Storage
Send/Sync
ties to thewasm
feature, and make keyDel in typescript compatible with the Rust code. Refactor theStorage
trait to return better errors, and simplify its API.Motivation
wasm
feature.MemStore
keyDel
slightly differs from the Rust code regarding idempotency.identity_account::types::signature::Signature::pkey
is not used in the Rust code.Storage::set_password
is no longer needed.To-do list
wasm
featurecfg_attr
on Storage and change the name of the feature that enables itStorage::key_del
should be idempotent or not. #729Account
Signature
not to containPublicKey
https://github.com/iotaledger/identity.rs/issues/722SetPassword
method fromStorage
https://github.com/iotaledger/identity.rs/issues/720Storage
interface, potentially reducing the number of state variablesError
forStorage
InterfaceStorage
implementations, including any type of file- or network-I/O-related failuresUInt8Array
rather than Base58-BTC encoded strings for keys. https://github.com/iotaledger/identity.rs/issues/721napi
related types and impl - #872NapiResult
error messagesChange checklist
Add an
x
to the boxes that are relevant to your changes, and delete any items that are not.