Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #107

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update `dusk-jubjub` `0.12` -> `0.13`
- Update `poseidon-merkle` `0.2.1-rc.0` -> `0.3`
- Update `rusk-abi` `0.10.0-piecrust.0.6` -> `0.11`
- Update dependencies
- Update `phoenix-core`: 0.21 -> 0.26
- Update `dusk-jubjub`: 0.13 -> 0.14
- Replace `dusk-schnorr` with `jubjub-schnorr` 0.2
- Replace `dusk-bls12_381-sign` with `bls12_381-bls` 0.2
- Update `dusk-poseidon` 0.31 -> 0.33
- Update `dusk-plonk` 0.16 -> 0.19
- Update `poseidon-merkle` 0.3 -> 0.5
- Rename `Wallet::public_key` to `Wallet::stake_public_key`
- Rename `Wallet::public_spend_key` to `Wallet::public_key`
- Rename `derive_sk` to `derive_stake_sk`
- Rename `derive_ssk` to `derive_sk`
- Rename `retrieve_sk` to `retrieve_stake_sk`
- Rename `retrieve_ssk` to `retrieve_sk`
- Rename `ffi::public_spend_key` to `ffi::public_key`
- Rename `UnprovenTransactionInput::pk_r` to `note_pk_prime`

### Fixed

Expand All @@ -70,6 +86,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Remove `get_block_height` from the `StateClient` trait [#58]
- Delete `extend_stake` since the stake contract removed it [#46]
- Remove `dusk-pki` dependency

## [0.5.1] - 2021-01-26

Expand Down
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ license = "MPL-2.0"
rand_core = "^0.6"
rand_chacha = { version = "^0.3", default-features = false }
sha2 = { version = "^0.10", default-features = false }
phoenix-core = { version = "0.21", default-features = false, features = ["alloc", "rkyv-impl"] }
dusk-pki = { version = "0.13", default-features = false }
phoenix-core = { version = "0.26", default-features = false, features = ["alloc", "rkyv-impl"] }
dusk-bytes = "^0.1"
dusk-schnorr = { version = "0.14", default-features = false }
dusk-jubjub = { version = "0.13", default-features = false }
dusk-poseidon = { version = "0.31", default-features = false }
poseidon-merkle = { version = "0.3", features = ["rkyv-impl"] }
dusk-plonk = { version = "0.16", default-features = false }
rusk-abi = { version = "0.12.0-rc", default-features = false }
dusk-bls12_381-sign = { version = "0.5", default-features = false }
jubjub-schnorr = { version = "0.2", default-features = false, features = ["double"] }
dusk-jubjub = { version = "0.14", default-features = false }
dusk-poseidon = { version = "0.33", default-features = false }
poseidon-merkle = { version = "0.5", features = ["rkyv-impl"] }
dusk-plonk = { version = "0.19", default-features = false }
bls12_381-bls = { version = "0.2", default-features = false }
rkyv = { version = "0.7", default-features = false }
ff = { version = "0.13", default-features = false }

stake-contract-types = "0.0.1-rc.2"
# rusk dependencies
rusk-abi = { version = "0.13.0-rc", default-features = false }
stake-contract-types = "0.1.0-rc"

[dev-dependencies]
rand = "^0.8"
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2023-01-05
nightly-2023-11-10
57 changes: 29 additions & 28 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ use core::mem;
use core::num::NonZeroU32;
use core::ptr;

use dusk_bls12_381_sign::PublicKey;
use dusk_bytes::Write;
use dusk_bytes::{DeserializableSlice, Serializable};
use bls12_381_bls::PublicKey as StakePublicKey;
use dusk_bytes::{DeserializableSlice, Serializable, Write};
use dusk_jubjub::{BlsScalar, JubJubAffine, JubJubScalar};
use dusk_pki::{PublicSpendKey, ViewKey};
use dusk_plonk::prelude::Proof;
use dusk_schnorr::Signature;
use phoenix_core::{Crossover, Fee, Note};
use jubjub_schnorr::Signature;
use phoenix_core::{Crossover, Fee, Note, PublicKey, ViewKey};
use poseidon_merkle::Opening as PoseidonOpening;
use rand_core::{
impls::{next_u32_via_fill, next_u64_via_fill},
Expand Down Expand Up @@ -85,7 +83,7 @@ extern "C" {
/// sequence, little endian, to the given buffer. If there is no value and
/// eligibility, the first 16 bytes should be zero.
fn fetch_stake(
pk: *const [u8; PublicKey::SIZE],
stake_pk: *const [u8; StakePublicKey::SIZE],
stake: *mut [u8; StakeInfo::SIZE],
) -> u8;

Expand Down Expand Up @@ -142,12 +140,12 @@ pub unsafe extern "C" fn free(ptr: *mut u8, cap: u32) {

/// Get the public spend key with the given index.
#[no_mangle]
pub unsafe extern "C" fn public_spend_key(
pub unsafe extern "C" fn public_key(
index: *const u64,
psk: *mut [u8; PublicSpendKey::SIZE],
pk: *mut [u8; PublicKey::SIZE],
) -> u8 {
let key = unwrap_or_bail!(WALLET.public_spend_key(*index)).to_bytes();
ptr::copy_nonoverlapping(&key[0], &mut (*psk)[0], key.len());
let key = unwrap_or_bail!(WALLET.public_key(*index)).to_bytes();
ptr::copy_nonoverlapping(&key[0], &mut (*pk)[0], key.len());
0
}

Expand All @@ -160,7 +158,7 @@ pub unsafe extern "C" fn execute(
call_data_ptr: *mut u8,
call_data_len: *const u32,
sender_index: *const u64,
refund: *const [u8; PublicSpendKey::SIZE],
refund: *const [u8; PublicKey::SIZE],
gas_limit: *const u64,
gas_price: *const u64,
) -> u8 {
Expand All @@ -182,7 +180,7 @@ pub unsafe extern "C" fn execute(
call_data_len as usize,
);

let refund = unwrap_or_bail!(PublicSpendKey::from_bytes(&*refund));
let refund = unwrap_or_bail!(PublicKey::from_bytes(&*refund));

unwrap_or_bail!(WALLET.execute(
&mut FfiRng,
Expand All @@ -202,15 +200,15 @@ pub unsafe extern "C" fn execute(
#[no_mangle]
pub unsafe extern "C" fn transfer(
sender_index: *const u64,
refund: *const [u8; PublicSpendKey::SIZE],
receiver: *const [u8; PublicSpendKey::SIZE],
refund: *const [u8; PublicKey::SIZE],
receiver: *const [u8; PublicKey::SIZE],
value: *const u64,
gas_limit: *const u64,
gas_price: *const u64,
ref_id: Option<&u64>,
) -> u8 {
let refund = unwrap_or_bail!(PublicSpendKey::from_bytes(&*refund));
let receiver = unwrap_or_bail!(PublicSpendKey::from_bytes(&*receiver));
let refund = unwrap_or_bail!(PublicKey::from_bytes(&*refund));
let receiver = unwrap_or_bail!(PublicKey::from_bytes(&*receiver));

let ref_id =
BlsScalar::from(ref_id.copied().unwrap_or_else(|| FfiRng.next_u64()));
Expand All @@ -234,12 +232,12 @@ pub unsafe extern "C" fn transfer(
pub unsafe extern "C" fn stake(
sender_index: *const u64,
staker_index: *const u64,
refund: *const [u8; PublicSpendKey::SIZE],
refund: *const [u8; PublicKey::SIZE],
value: *const u64,
gas_limit: *const u64,
gas_price: *const u64,
) -> u8 {
let refund = unwrap_or_bail!(PublicSpendKey::from_bytes(&*refund));
let refund = unwrap_or_bail!(PublicKey::from_bytes(&*refund));

unwrap_or_bail!(WALLET.stake(
&mut FfiRng,
Expand All @@ -259,11 +257,11 @@ pub unsafe extern "C" fn stake(
pub unsafe extern "C" fn unstake(
sender_index: *const u64,
staker_index: *const u64,
refund: *const [u8; PublicSpendKey::SIZE],
refund: *const [u8; PublicKey::SIZE],
gas_limit: *const u64,
gas_price: *const u64,
) -> u8 {
let refund = unwrap_or_bail!(PublicSpendKey::from_bytes(&*refund));
let refund = unwrap_or_bail!(PublicKey::from_bytes(&*refund));

unwrap_or_bail!(WALLET.unstake(
&mut FfiRng,
Expand All @@ -283,11 +281,11 @@ pub unsafe extern "C" fn unstake(
pub unsafe extern "C" fn withdraw(
sender_index: *const u64,
staker_index: *const u64,
refund: *const [u8; PublicSpendKey::SIZE],
refund: *const [u8; PublicKey::SIZE],
gas_limit: *const u64,
gas_price: *const u64,
) -> u8 {
let refund = unwrap_or_bail!(PublicSpendKey::from_bytes(&*refund));
let refund = unwrap_or_bail!(PublicKey::from_bytes(&*refund));

unwrap_or_bail!(WALLET.withdraw(
&mut FfiRng,
Expand All @@ -304,10 +302,10 @@ pub unsafe extern "C" fn withdraw(
/// Gets the balance of a secret spend key.
#[no_mangle]
pub unsafe extern "C" fn get_balance(
ssk_index: *const u64,
sk_index: *const u64,
balance: *mut [u8; BalanceInfo::SIZE],
) -> u8 {
let b = unwrap_or_bail!(WALLET.get_balance(*ssk_index)).to_bytes();
let b = unwrap_or_bail!(WALLET.get_balance(*sk_index)).to_bytes();
ptr::copy_nonoverlapping(&b[0], &mut (*balance)[0], b.len());
0
}
Expand Down Expand Up @@ -496,12 +494,15 @@ impl StateClient for FfiStateClient {
Ok(branch)
}

fn fetch_stake(&self, pk: &PublicKey) -> Result<StakeInfo, Self::Error> {
let pk = pk.to_bytes();
fn fetch_stake(
&self,
stake_pk: &StakePublicKey,
) -> Result<StakeInfo, Self::Error> {
let stake_pk = stake_pk.to_bytes();
let mut stake_buf = [0u8; StakeInfo::SIZE];

unsafe {
let r = fetch_stake(&pk, &mut stake_buf);
let r = fetch_stake(&stake_pk, &mut stake_buf);
if r != 0 {
return Err(r);
}
Expand Down
Loading
Loading