Remove artifacts for serai-processor-ethereum-contracts

This commit is contained in:
Luke Parker
2024-09-15 12:04:57 -04:00
parent 3f0f4d520d
commit 39be23d807
15 changed files with 5501 additions and 69 deletions

View File

@@ -38,6 +38,7 @@ alloy-provider = { version = "0.3", default-features = false }
alloy-node-bindings = { version = "0.3", default-features = false, optional = true }
ethereum-schnorr-contract = { path = "../../../networks/ethereum/schnorr", default-features = false }
contracts = { package = "serai-processor-ethereum-contracts", path = "../contracts" }
[dev-dependencies]

View File

@@ -13,6 +13,8 @@ use frost::{
curve::{Ciphersuite, Secp256k1},
};
pub use ethereum_schnorr_contract::*;
use alloy_core::primitives::{Parity, Signature as AlloySignature};
use alloy_consensus::{SignableTransaction, Signed, TxLegacy};
@@ -77,11 +79,3 @@ impl Hram<Secp256k1> for EthereumHram {
<Scalar as Reduce<KU256>>::reduce_bytes(&keccak256(&data).into())
}
}
impl From<&Signature> for AbiSignature {
fn from(sig: &Signature) -> AbiSignature {
let c: [u8; 32] = sig.c.to_repr().into();
let s: [u8; 32] = sig.s.to_repr().into();
AbiSignature { c: c.into(), s: s.into() }
}
}

View File

@@ -236,7 +236,7 @@ impl RouterCommand {
writer.write_all(&[0])?;
writer.write_all(&chain_id.as_le_bytes())?;
writer.write_all(&nonce.as_le_bytes())?;
writer.write_all(&key.A.to_bytes())
writer.write_all(&key.point().to_bytes())
}
RouterCommand::Execute { chain_id, nonce, outs } => {
writer.write_all(&[1])?;
@@ -406,9 +406,9 @@ impl SignatureMachine<SignedRouterCommand> for RouterCommandSignatureMachine {
self,
shares: HashMap<Participant, Self::SignatureShare>,
) -> Result<SignedRouterCommand, FrostError> {
let sig = self.machine.complete(shares)?;
let signature = Signature::new(&self.key, &self.command.msg(), sig)
.expect("machine produced an invalid signature");
let signature = self.machine.complete(shares)?;
let signature = Signature::new(signature).expect("machine produced an invalid signature");
assert!(signature.verify(&self.key, &self.command.msg()));
Ok(SignedRouterCommand { command: self.command, signature })
}
}

View File

@@ -127,7 +127,6 @@ impl InInstruction {
pub struct Executed {
pub tx_id: [u8; 32],
pub nonce: u64,
pub signature: [u8; 64],
}
/// The contract Serai uses to manage its state.
@@ -142,7 +141,7 @@ impl Router {
pub(crate) fn init_code(key: &PublicKey) -> Vec<u8> {
let mut bytecode = Self::code();
// Append the constructor arguments
bytecode.extend((abi::constructorCall { _seraiKey: key.eth_repr().into() }).abi_encode());
bytecode.extend((abi::constructorCall { initialSeraiKey: key.eth_repr().into() }).abi_encode());
bytecode
}
@@ -392,13 +391,9 @@ impl Router {
let log =
log.log_decode::<SeraiKeyUpdated>().map_err(|_| Error::ConnectionError)?.inner.data;
let mut signature = [0; 64];
signature[.. 32].copy_from_slice(log.signature.c.as_ref());
signature[32 ..].copy_from_slice(log.signature.s.as_ref());
res.push(Executed {
tx_id,
nonce: log.nonce.try_into().map_err(|_| Error::ConnectionError)?,
signature,
});
}
}
@@ -418,13 +413,9 @@ impl Router {
let log = log.log_decode::<ExecutedEvent>().map_err(|_| Error::ConnectionError)?.inner.data;
let mut signature = [0; 64];
signature[.. 32].copy_from_slice(log.signature.c.as_ref());
signature[32 ..].copy_from_slice(log.signature.s.as_ref());
res.push(Executed {
tx_id,
nonce: log.nonce.try_into().map_err(|_| Error::ConnectionError)?,
signature,
});
}
}