feat(wallet): implement HD private keys & encrypted wrapper (#358)

This commit is contained in:
Harper 2023-12-23 17:24:32 +01:00 committed by GitHub
parent 8b13646680
commit 550eac147b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 413 additions and 175 deletions

View file

@ -18,6 +18,7 @@ pallas-crypto = { path = "../pallas-crypto", version = "=0.20.0" }
pallas-primitives = { path = "../pallas-primitives", version = "=0.20.0" }
pallas-traverse = { path = "../pallas-traverse", version = "=0.20.0" }
pallas-addresses = { path = "../pallas-addresses", version = "=0.20.0" }
pallas-wallet = { path = "../pallas-wallet", version = "=0.20.0" }
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
thiserror = "1.0.44"

View file

@ -4,6 +4,7 @@ use pallas_crypto::{
key::ed25519,
};
use pallas_primitives::{babbage, Fragment};
use pallas_wallet::PrivateKey;
use std::{collections::HashMap, ops::Deref};
@ -608,14 +609,14 @@ pub struct BuiltTransaction {
}
impl BuiltTransaction {
pub fn sign(mut self, secret_key: ed25519::SecretKey) -> Result<Self, TxBuilderError> {
let pubkey: [u8; 32] = secret_key
pub fn sign(mut self, private_key: PrivateKey) -> Result<Self, TxBuilderError> {
let pubkey: [u8; 32] = private_key
.public_key()
.as_ref()
.try_into()
.map_err(|_| TxBuilderError::MalformedKey)?;
let signature: [u8; 64] = secret_key.sign(self.tx_hash.0).as_ref().try_into().unwrap();
let signature: [u8; ed25519::Signature::SIZE] = private_key.sign(self.tx_hash.0).as_ref().try_into().unwrap();
match self.era {
BuilderEra::Babbage => {