chore: regenerate umbrella crate, fix feature propagation
This commit is contained in:
@@ -20,9 +20,9 @@
|
||||
// end::description[]
|
||||
|
||||
use aes_gcm::{aead::Aead, AeadCore, KeyInit};
|
||||
use pezsp_core::crypto::Pair;
|
||||
use rand::rngs::OsRng;
|
||||
use sha2::Digest;
|
||||
use pezsp_core::crypto::Pair;
|
||||
|
||||
/// x25519 secret key.
|
||||
pub type SecretKey = x25519_dalek::StaticSecret;
|
||||
@@ -92,7 +92,10 @@ pub fn encrypt_x25519(pk: &PublicKey, plaintext: &[u8]) -> Result<Vec<u8>, Error
|
||||
|
||||
/// Encrypt `plaintext` with the given ed25519 public key. Decryption can be performed with the
|
||||
/// matching secret key.
|
||||
pub fn encrypt_ed25519(pk: &pezsp_core::ed25519::Public, plaintext: &[u8]) -> Result<Vec<u8>, Error> {
|
||||
pub fn encrypt_ed25519(
|
||||
pk: &pezsp_core::ed25519::Public,
|
||||
plaintext: &[u8],
|
||||
) -> Result<Vec<u8>, Error> {
|
||||
let ed25519 = curve25519_dalek::edwards::CompressedEdwardsY(pk.0);
|
||||
let x25519 = ed25519.decompress().ok_or(Error::BadData)?.to_montgomery();
|
||||
let montgomery = x25519_dalek::PublicKey::from(x25519.to_bytes());
|
||||
@@ -118,7 +121,10 @@ pub fn decrypt_x25519(sk: &SecretKey, encrypted: &[u8]) -> Result<Vec<u8>, Error
|
||||
}
|
||||
|
||||
/// Decrypt with the given ed25519 key pair.
|
||||
pub fn decrypt_ed25519(pair: &pezsp_core::ed25519::Pair, encrypted: &[u8]) -> Result<Vec<u8>, Error> {
|
||||
pub fn decrypt_ed25519(
|
||||
pair: &pezsp_core::ed25519::Pair,
|
||||
encrypted: &[u8],
|
||||
) -> Result<Vec<u8>, Error> {
|
||||
let raw = pair.to_raw_vec();
|
||||
let hash: [u8; 32] = sha2::Sha512::digest(&raw).as_slice()[..32]
|
||||
.try_into()
|
||||
@@ -130,8 +136,8 @@ pub fn decrypt_ed25519(pair: &pezsp_core::ed25519::Pair, encrypted: &[u8]) -> Re
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use rand::rngs::OsRng;
|
||||
use pezsp_core::crypto::Pair;
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
#[test]
|
||||
fn basic_x25519_encryption() {
|
||||
|
||||
@@ -24,10 +24,10 @@ extern crate alloc;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_application_crypto::RuntimeAppPublic;
|
||||
#[cfg(feature = "std")]
|
||||
use pezsp_core::Pair;
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// Statement topic.
|
||||
pub type Topic = [u8; 32];
|
||||
@@ -175,7 +175,9 @@ impl Field {
|
||||
}
|
||||
|
||||
/// Statement structure.
|
||||
#[derive(DecodeWithMemTracking, TypeInfo, pezsp_core::RuntimeDebug, Clone, PartialEq, Eq, Default)]
|
||||
#[derive(
|
||||
DecodeWithMemTracking, TypeInfo, pezsp_core::RuntimeDebug, Clone, PartialEq, Eq, Default,
|
||||
)]
|
||||
pub struct Statement {
|
||||
proof: Option<Proof>,
|
||||
decryption_key: Option<DecryptionKey>,
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
use crate::{Hash, Statement, Topic};
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::RuntimeDebug;
|
||||
use pezsp_runtime_interface::{
|
||||
pass_by::{
|
||||
@@ -29,6 +28,7 @@ use pezsp_runtime_interface::{
|
||||
},
|
||||
runtime_interface,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use pezsp_externalities::ExternalitiesExt;
|
||||
|
||||
Reference in New Issue
Block a user