Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Resolves #106
  • Loading branch information
moCello committed May 8, 2024
1 parent ffef2d6 commit d5248b2
Show file tree
Hide file tree
Showing 18 changed files with 318 additions and 282 deletions.
33 changes: 17 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.21.6"
edition = "2021"
description = "The core functionality of the Dusk wallet"
license = "MPL-2.0"
respository = "https://github.com/dusk-network/wallet-core"
repository = "https://github.com/dusk-network/wallet-core"

[lib]
crate-type = ["cdylib", "rlib"]
Expand All @@ -15,21 +15,22 @@ bs58 = { version = "0.5", default-features = false, features = [
"alloc",
"cb58",
] }
dusk-bls12_381-sign = { version = "0.5", default-features = false }
bls12_381-bls = { version = "0.2", default-features = false }
dusk-bytes = "0.1.7"
dusk-jubjub = { version = "0.13.1", default-features = false }
dusk-pki = { version = "0.13", default-features = false, features = [
"rkyv-impl",
] }
dusk-schnorr = { version = "0.14", default-features = false, features = [
dusk-jubjub = { version = "0.14", default-features = false }
# dusk-pki = { version = "0.13", default-features = false, features = [
# "rkyv-impl",
# ] }
jubjub-schnorr = { version = "0.2", default-features = false, features = [
"rkyv-impl",
"alloc",
"double",
] }
phoenix-core = { version = "0.21", default-features = false, features = [
phoenix-core = { version = "0.26", default-features = false, features = [
"alloc",
"rkyv-impl",
] }
poseidon-merkle = { version = "0.3", features = ["rkyv-impl"] }
poseidon-merkle = { version = "0.5", features = ["rkyv-impl"] }
rand_chacha = { version = "^0.3", default-features = false }
rand_core = "^0.6"
rkyv = { version = "^0.7", default-features = false, features = ["size_32"] }
Expand All @@ -40,22 +41,22 @@ serde = { version = "1.0", default-features = false, features = [
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
sha2 = { version = "^0.10", default-features = false }
bip39 = { version = "2.0.0", optional = true, default-features = false }
dusk-plonk = { version = "0.16", default-features = false, features = [
dusk-plonk = { version = "0.19", default-features = false, features = [
"alloc",
"rkyv-impl",
] }
dusk-poseidon = { version = "0.31", default-features = false, features = [
dusk-poseidon = { version = "0.33", default-features = false, features = [
"alloc",
"rkyv-impl",
] }
ff = { version = "0.13", default-features = false }
dusk-bls12_381 = { version = "0.12.3", default-features = false, features = [
dusk-bls12_381 = { version = "0.13", default-features = false, features = [
"alloc",
"rkyv-impl",
] }
hex = { version = "0.4", default_features = false, features = ["alloc"] }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
hashbrown = "0.14.3"
stake-contract-types = "0.0.1-rc.2"
stake-contract-types = "0.1.0-rc"


[features]
Expand All @@ -64,10 +65,10 @@ default = ["compat"]
compat = ["dep:bip39"]

[target.'cfg(target_family = "wasm")'.dependencies]
rusk-abi = "0.12.0-rc.0"
rusk-abi = "0.13.0-rc"

[target.'cfg(not(target_family = "wasm"))'.dependencies]
rusk-abi = { version = "0.12.0-rc.0", default-features = false }
rusk-abi = { version = "0.13.0-rc", default-features = false }

[dev-dependencies]
rand = "^0.8"
Expand Down
Binary file modified assets/dusk_wallet_core.wasm
Binary file not shown.
44 changes: 22 additions & 22 deletions assets/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@
}
}
},
"PublicSpendKeysArgs": {
"description": "The arguments of the public_spend_keys function",
"PublicKeysArgs": {
"description": "The arguments of the public_keys function",
"type": "object",
"required": [
"seed"
Expand All @@ -351,15 +351,15 @@
}
}
},
"PublicSpendKeysResponse": {
"description": "The response of the public_spend_keys function",
"PublicKeysResponse": {
"description": "The response of the public_keys function",
"type": "object",
"required": [
"keys"
],
"properties": {
"keys": {
"description": "The Base58 public spend keys of the wallet.",
"description": "The Base58 public keys of the wallet.",
"type": "array",
"items": {
"type": "string"
Expand Down Expand Up @@ -449,7 +449,7 @@
}
},
"RkyvTreeLeafResponse": {
"description": "The response of the public_spend_keys function",
"description": "The response of the public_keys function",
"type": "object",
"required": [
"block_height",
Expand Down Expand Up @@ -557,13 +557,13 @@
}
}
},
"PublicSpendKeysAndNotesType": {
"PublicKeysAndNotesType": {
"description": "Type of the response of the check_note_validity function",
"type": "object",
"required": ["public_spend_key", "notes"],
"required": ["public_key", "notes"],
"properties": {
"public_spend_key": {
"description": "The public spend key as a bs58 formated string",
"public_key": {
"description": "The public key as a bs58 formated string",
"type": "string"
},
"notes": {
Expand Down Expand Up @@ -616,8 +616,8 @@
"format": "uint8"
}
},
"public_spend_key": {
"description": "A base 58 encoded public spend key string",
"public_key": {
"description": "A base 58 encoded public key string",
"type": "string"
}
}
Expand Down Expand Up @@ -745,7 +745,7 @@
"UnspentSpentNotesArgs": {
"description": "Arguents of the unspent_spent_notes function",
"type": "object",
"required": ["notes", "nullifiers_of_notes", "block_heights", "existing_nullifiers", "psks"],
"required": ["notes", "nullifiers_of_notes", "block_heights", "existing_nullifiers", "pks"],
"properties": {
"notes": {
"description": "The Array<UInt8Array> of rkyv serialized notes",
Expand Down Expand Up @@ -785,7 +785,7 @@
"format": "uint8"
}
},
"psks": {
"pks": {
"description": "Array of bs58 encoded string to be sent with the response of the function",
"type": "array",
"items": {
Expand Down Expand Up @@ -818,14 +818,14 @@
"NoteInfoType": {
"description": "Information about the note",
"type": "object",
"required": ["pos", "psk", "note", "nullifier", "block_height"],
"required": ["pos", "pk", "note", "nullifier", "block_height"],
"properties": {
"pos": {
"description": "position of the note",
"type": "integer"
},
"psk": {
"description": "public spend key belonging to that note",
"pk": {
"description": "public key belonging to that note",
"type": "string"
},
"note": {
Expand Down Expand Up @@ -944,7 +944,7 @@
"GetStakeCallDataArgs": {
"description": "Get the call data for stakeing",
"type": "object",
"required": ["staker_index", "seed", "spend_proof", "value", "counter"],
"required": ["staker_index", "seed", "proof", "value", "counter"],
"properties": {
"staker_index": {
"description": "Index of the address of the staker in the seed",
Expand All @@ -959,7 +959,7 @@
"format": "uint8"
}
},
"spend_proof": {
"proof": {
"description": "The stct proof as recieved from the node",
"type": "array",
"items": {
Expand Down Expand Up @@ -1076,8 +1076,8 @@
}
}
},
"GetPublicKeyRkyvSerializedArgs": {
"description": "Args of the get_public_key_rkyv_serialized function",
"GetStakePKrkyvSerializedArgs": {
"description": "Args of the get_stake_pk_rkyv_serialized function",
"type": "object",
"required": ["seed", "index"],
"properties": {
Expand Down Expand Up @@ -1211,7 +1211,7 @@
"format": "uint64"
},
"refund": {
"description": "psk in string of who to refund this tx to",
"description": "pk in string of who to refund this tx to",
"type": "string"
},
"owner_index": {
Expand Down
26 changes: 14 additions & 12 deletions src/compat/allow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ use crate::{key::*, types, utils, MAX_LEN};

use alloc::string::String;

use dusk_bls12_381_sign::PublicKey;
use bls12_381_bls::PublicKey as StakePublicKey;
use dusk_jubjub::JubJubScalar;
use phoenix_core::{Note, *};

use super::stake_contract_types::*;
use ff::Field;
use phoenix_core::{
transaction::{allow_signature_message, Allow},
Crossover, Fee, Note, PublicKey,
};

/// Get unstake call data
#[no_mangle]
Expand Down Expand Up @@ -41,23 +43,23 @@ pub fn get_allow_call_data(args: i32, len: i32) -> i64 {
None => return utils::fail(),
};

let refund: dusk_pki::PublicSpendKey = match utils::bs58_to_psk(&refund) {
let refund: PublicKey = match utils::bs58_to_pk(&refund) {
Some(a) => a,
None => return utils::fail(),
};

let sk = derive_sk(&seed, owner_index);
let staker = PublicKey::from(&sk);
let stake_sk = derive_stake_sk(&seed, owner_index);
let staker_pk = StakePublicKey::from(&stake_sk);

let owner_sk = derive_sk(&seed, sender_index);
let owner_pk = PublicKey::from(&owner_sk);
let owner_sk = derive_stake_sk(&seed, sender_index);
let owner_pk = StakePublicKey::from(&owner_sk);

let rng = &mut utils::rng(rng_seed);

let msg = allow_signature_message(counter, &staker);
let msg = allow_signature_message(counter, staker_pk);
let signature = owner_sk.sign(&owner_pk, &msg);

let blinder = JubJubScalar::random(rng);
let blinder = JubJubScalar::random(&mut *rng);
let note = Note::obfuscated(rng, &refund, 0, blinder);
let (mut fee, crossover) = note
.try_into()
Expand All @@ -67,7 +69,7 @@ pub fn get_allow_call_data(args: i32, len: i32) -> i64 {
fee.gas_price = gas_price;

let allow = Allow {
public_key: staker,
public_key: staker_pk,
owner: owner_pk,
signature,
};
Expand Down
29 changes: 14 additions & 15 deletions src/compat/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use dusk_bls12_381::BlsScalar;
use dusk_bytes::Serializable;
use phoenix_core::Note;
use phoenix_core::{Note, PublicKey, ViewKey};

use alloc::vec::Vec;

Expand Down Expand Up @@ -41,26 +41,25 @@ pub fn check_note_ownership(args: i32, len: i32) -> i64 {

let mut is_owned: bool = false;
let mut nullifier_found = BlsScalar::default();
let mut psk_found: Option<dusk_pki::PublicSpendKey> = None;
let mut pk_found: Option<PublicKey> = None;

for idx in 0..=MAX_KEY {
let idx = idx as u64;
let view_key = key::derive_vk(&seed, idx);
let sk = key::derive_sk(&seed, idx);
let vk = ViewKey::from(&sk);

if view_key.owns(&note) {
let ssk = key::derive_ssk(&seed, idx);
let nullifier = note.gen_nullifier(&ssk);
if vk.owns(&note) {
let nullifier = note.gen_nullifier(&sk);

nullifier_found = nullifier;
is_owned = true;
psk_found = Some(ssk.public_spend_key());
pk_found = Some(PublicKey::from(&sk));

break;
}
}

let psk_found =
psk_found.map(|psk| bs58::encode(psk.to_bytes()).into_string());
let pk_found = pk_found.map(|pk| bs58::encode(pk.to_bytes()).into_string());

let nullifier_found =
match rkyv::to_bytes::<BlsScalar, MAX_LEN>(&nullifier_found).ok() {
Expand All @@ -71,7 +70,7 @@ pub fn check_note_ownership(args: i32, len: i32) -> i64 {
utils::into_ptr(types::CheckNoteOwnershipResponse {
is_owned,
nullifier: nullifier_found,
public_spend_key: psk_found,
public_key: pk_found,
})
}

Expand All @@ -84,7 +83,7 @@ pub fn unspent_spent_notes(args: i32, len: i32) -> i64 {
nullifiers_of_notes,
block_heights,
existing_nullifiers,
psks,
pks,
} = match utils::take_args(args, len) {
Some(a) => a,
None => return utils::fail(),
Expand All @@ -99,10 +98,10 @@ pub fn unspent_spent_notes(args: i32, len: i32) -> i64 {
let mut spent_notes = Vec::new();
let mut unspent_notes = Vec::new();

for (index, ((note, nullifier), psk)) in notes
for (index, ((note, nullifier), pk)) in notes
.into_iter()
.zip(nullifiers_of_notes)
.zip(psks)
.zip(pks)
.enumerate()
{
let parsed_note: Note = match rkyv::from_bytes::<Note>(&note).ok() {
Expand All @@ -124,7 +123,7 @@ pub fn unspent_spent_notes(args: i32, len: i32) -> i64 {
if existing_nullifiers.contains(&parsed_nullifier) {
spent_notes.push(types::NoteInfoType {
pos: *parsed_note.pos(),
psk,
pk,
block_height,
note,
nullifier,
Expand All @@ -134,7 +133,7 @@ pub fn unspent_spent_notes(args: i32, len: i32) -> i64 {
pos: *parsed_note.pos(),
note,
block_height,
psk,
pk,
nullifier,
});
}
Expand Down
8 changes: 0 additions & 8 deletions src/compat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,3 @@ pub mod tx;
pub mod unstake;
/// Includes functions to interact with the stake contract withdraw tx
pub mod withdraw;

mod stake_contract_types {
pub use stake_contract_types::{
allow_signature_message, stake_signature_message,
unstake_signature_message, withdraw_signature_message,
};
pub use stake_contract_types::{Allow, Stake, Unstake, Withdraw};
}
Loading

0 comments on commit d5248b2

Please sign in to comment.