mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-05 06:43:08 +00:00
rm core primitives
This commit is contained in:
parent
8e4956891c
commit
7336ccb660
@ -1,27 +0,0 @@
|
||||
[package]
|
||||
name = "core_primitives"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
serde_json.workspace = true
|
||||
env_logger.workspace = true
|
||||
log.workspace = true
|
||||
serde.workspace = true
|
||||
sha2.workspace = true
|
||||
elliptic-curve.workspace = true
|
||||
monotree.workspace = true
|
||||
|
||||
[dependencies.secp256k1-zkp]
|
||||
workspace = true
|
||||
features = ["std", "rand-std", "rand", "serde", "global-context"]
|
||||
|
||||
[dependencies.storage]
|
||||
path = "../storage"
|
||||
|
||||
[dependencies.sequencer_core]
|
||||
path = "../sequencer_core"
|
||||
|
||||
[dependencies.common]
|
||||
path = "../common"
|
||||
@ -1,16 +0,0 @@
|
||||
use crate::merkle_tree_public::CommitmentHashType;
|
||||
use monotree::database::MemoryDB;
|
||||
use monotree::hasher::Blake3;
|
||||
use monotree::Monotree;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq)]
|
||||
pub struct Commitment {
|
||||
pub commitment_hash: CommitmentHashType,
|
||||
}
|
||||
|
||||
pub struct CommitmentsSparseMerkleTree {
|
||||
pub curr_root: Option<CommitmentHashType>,
|
||||
pub tree: Monotree<MemoryDB, Blake3>,
|
||||
pub hasher: Blake3,
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
pub mod commitment;
|
||||
pub mod merkle_tree_public;
|
||||
pub mod nullifier;
|
||||
pub mod transaction;
|
||||
pub mod utxo;
|
||||
@ -1,2 +0,0 @@
|
||||
pub type TreeHashType = [u8; 32];
|
||||
pub type CommitmentHashType = Vec<u8>;
|
||||
@ -1,18 +0,0 @@
|
||||
use crate::merkle_tree_public::TreeHashType;
|
||||
use monotree::database::MemoryDB;
|
||||
use monotree::hasher::Blake3;
|
||||
use monotree::Monotree;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
//ToDo: Update Nullifier model, when it is clear
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq)]
|
||||
///General nullifier object
|
||||
pub struct UTXONullifier {
|
||||
pub utxo_hash: TreeHashType,
|
||||
}
|
||||
|
||||
pub struct NullifierSparseMerkleTree {
|
||||
pub curr_root: Option<TreeHashType>,
|
||||
pub tree: Monotree<MemoryDB, Blake3>,
|
||||
pub hasher: Blake3,
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::merkle_tree_public::TreeHashType;
|
||||
|
||||
use elliptic_curve::{
|
||||
consts::{B0, B1},
|
||||
generic_array::GenericArray,
|
||||
};
|
||||
use secp256k1_zkp::PedersenCommitment;
|
||||
use sha2::digest::typenum::{UInt, UTerm};
|
||||
|
||||
pub type CipherText = Vec<u8>;
|
||||
pub type Nonce = GenericArray<u8, UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>>;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
|
||||
pub enum TxKind {
|
||||
Public,
|
||||
Private,
|
||||
Shielded,
|
||||
Deshielded,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
///General transaction object
|
||||
pub struct Transaction {
|
||||
pub hash: TreeHashType,
|
||||
pub tx_kind: TxKind,
|
||||
///Tx input data (public part)
|
||||
pub execution_input: Vec<u8>,
|
||||
///Tx output data (public_part)
|
||||
pub execution_output: Vec<u8>,
|
||||
///Tx input utxo commitments
|
||||
pub utxo_commitments_spent_hashes: Vec<TreeHashType>,
|
||||
///Tx output utxo commitments
|
||||
pub utxo_commitments_created_hashes: Vec<TreeHashType>,
|
||||
///Tx output nullifiers
|
||||
pub nullifier_created_hashes: Vec<TreeHashType>,
|
||||
///Execution proof (private part)
|
||||
pub execution_proof_private: String,
|
||||
///Encoded blobs of data
|
||||
pub encoded_data: Vec<(CipherText, Vec<u8>)>,
|
||||
///Transaction senders ephemeral pub key
|
||||
pub ephemeral_pub_key: Vec<u8>,
|
||||
///Public (Pedersen) commitment
|
||||
pub commitment: PedersenCommitment,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
///General transaction object
|
||||
pub struct TransactionPayload {
|
||||
pub tx_kind: TxKind,
|
||||
///Tx input data (public part)
|
||||
pub execution_input: Vec<u8>,
|
||||
///Tx output data (public_part)
|
||||
pub execution_output: Vec<u8>,
|
||||
///Tx input utxo commitments
|
||||
pub utxo_commitments_spent_hashes: Vec<TreeHashType>,
|
||||
///Tx output utxo commitments
|
||||
pub utxo_commitments_created_hashes: Vec<TreeHashType>,
|
||||
///Tx output nullifiers
|
||||
pub nullifier_created_hashes: Vec<TreeHashType>,
|
||||
///Execution proof (private part)
|
||||
pub execution_proof_private: String,
|
||||
///Encoded blobs of data
|
||||
pub encoded_data: Vec<(CipherText, Vec<u8>)>,
|
||||
///Transaction senders ephemeral pub key
|
||||
pub ephemeral_pub_key: Vec<u8>,
|
||||
///Public (Pedersen) commitment
|
||||
pub commitment: PedersenCommitment,
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
use common::{merkle_tree_public::TreeHashType, nullifier::UTXONullifier, AccountId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
///Raw asset data
|
||||
pub type Asset = Vec<u8>;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
|
||||
///Container for raw utxo payload
|
||||
pub struct UTXO {
|
||||
pub hash: TreeHashType,
|
||||
pub owner: AccountId,
|
||||
pub nullifier: Option<UTXONullifier>,
|
||||
pub asset: Asset,
|
||||
// TODO: change to u256
|
||||
pub amount: u128,
|
||||
pub privacy_flag: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct UTXOPayload {
|
||||
pub owner: AccountId,
|
||||
pub asset: Asset,
|
||||
// TODO: change to u256
|
||||
pub amount: u128,
|
||||
pub privacy_flag: bool,
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user