Skip to content

Commit

Permalink
fix acronym's all-caps (clippy warning);
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat committed Mar 26, 2021
1 parent b28059c commit 30be67d
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 70 deletions.
14 changes: 7 additions & 7 deletions bindings/ergo-lib-wasm/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ impl From<ergo_lib::ergotree_ir::address::NetworkPrefix> for NetworkPrefix {
#[repr(u8)]
pub enum AddressTypePrefix {
/// 0x01 - Pay-to-PublicKey(P2PK) address
P2PK = 1,
P2Pk = 1,
/// 0x02 - Pay-to-Script-Hash(P2SH)
Pay2SH = 2,
Pay2Sh = 2,
/// 0x03 - Pay-to-Script(P2S)
Pay2S = 3,
}
Expand All @@ -54,8 +54,8 @@ impl From<AddressTypePrefix> for ergo_lib::ergotree_ir::address::AddressTypePref
fn from(v: AddressTypePrefix) -> Self {
use ergo_lib::ergotree_ir::address::AddressTypePrefix::*;
match v {
AddressTypePrefix::P2PK => P2PK,
AddressTypePrefix::Pay2SH => Pay2SH,
AddressTypePrefix::P2Pk => P2Pk,
AddressTypePrefix::Pay2Sh => Pay2Sh,
AddressTypePrefix::Pay2S => Pay2S,
}
}
Expand All @@ -65,8 +65,8 @@ impl From<ergo_lib::ergotree_ir::address::AddressTypePrefix> for AddressTypePref
fn from(v: ergo_lib::ergotree_ir::address::AddressTypePrefix) -> Self {
use AddressTypePrefix::*;
match v {
ergo_lib::ergotree_ir::address::AddressTypePrefix::P2PK => P2PK,
ergo_lib::ergotree_ir::address::AddressTypePrefix::Pay2SH => Pay2SH,
ergo_lib::ergotree_ir::address::AddressTypePrefix::P2Pk => P2Pk,
ergo_lib::ergotree_ir::address::AddressTypePrefix::Pay2Sh => Pay2Sh,
ergo_lib::ergotree_ir::address::AddressTypePrefix::Pay2S => Pay2S,
}
}
Expand Down Expand Up @@ -198,7 +198,7 @@ impl Address {
/// Create an address from a public key
pub fn from_public_key(bytes: &[u8]) -> Result<Address, JsValue> {
EcPoint::sigma_parse_bytes(bytes.to_vec())
.map(|point| ergo_lib::ergotree_ir::address::Address::P2PK(ProveDlog::new(point)))
.map(|point| ergo_lib::ergotree_ir::address::Address::P2Pk(ProveDlog::new(point)))
.map(Address)
.map_err(|e| JsValue::from_str(&format!("{}", e)))
}
Expand Down
2 changes: 1 addition & 1 deletion ergo-lib/src/wallet/secret_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl SecretKey {
/// Address (encoded public image)
pub fn get_address_from_public_image(&self) -> Address {
match self {
SecretKey::DlogSecretKey(dpi) => Address::P2PK(dpi.public_image()),
SecretKey::DlogSecretKey(dpi) => Address::P2Pk(dpi.public_image()),
}
}

Expand Down
48 changes: 24 additions & 24 deletions ergotree-interpreter/src/eval/bin_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ impl Evaluable for BinOp {
BinOpKind::Relation(op) => match op {
RelationOp::Eq => Ok(Value::Boolean(lv == rv()?)),
RelationOp::NEq => Ok(Value::Boolean(lv != rv()?)),
RelationOp::GT => eval_gt(lv, rv()?),
RelationOp::LT => eval_lt(lv, rv()?),
RelationOp::GE => eval_ge(lv, rv()?),
RelationOp::LE => eval_le(lv, rv()?),
RelationOp::Gt => eval_gt(lv, rv()?),
RelationOp::Lt => eval_lt(lv, rv()?),
RelationOp::Ge => eval_ge(lv, rv()?),
RelationOp::Le => eval_le(lv, rv()?),
RelationOp::And => Ok(Value::Boolean(if lv.try_extract_into::<bool>()? {
rv()?.try_extract_into::<bool>()?
} else {
Expand Down Expand Up @@ -410,10 +410,10 @@ mod tests {
prop_assert_eq!(eval_num_op::<i64>(ArithOp::Max, l.into(), r.into()).unwrap(), l.max(r));
prop_assert_eq!(eval_num_op::<i64>(ArithOp::Min, l.into(), r.into()).unwrap(), l.min(r));

prop_assert_eq!(eval_relation_op(RelationOp::GT, l.into(), r.into()), l > r);
prop_assert_eq!(eval_relation_op(RelationOp::LT, l.into(), r.into()), l < r);
prop_assert_eq!(eval_relation_op(RelationOp::GE, l.into(), r.into()), l >= r);
prop_assert_eq!(eval_relation_op(RelationOp::LE, l.into(), r.into()), l <= r);
prop_assert_eq!(eval_relation_op(RelationOp::Gt, l.into(), r.into()), l > r);
prop_assert_eq!(eval_relation_op(RelationOp::Lt, l.into(), r.into()), l < r);
prop_assert_eq!(eval_relation_op(RelationOp::Ge, l.into(), r.into()), l >= r);
prop_assert_eq!(eval_relation_op(RelationOp::Le, l.into(), r.into()), l <= r);
}

#[test]
Expand All @@ -425,10 +425,10 @@ mod tests {
prop_assert_eq!(eval_num_op::<i32>(ArithOp::Max, l.into(), r.into()).unwrap(), l.max(r));
prop_assert_eq!(eval_num_op::<i32>(ArithOp::Min, l.into(), r.into()).unwrap(), l.min(r));

prop_assert_eq!(eval_relation_op(RelationOp::GT, l.into(), r.into()), l > r);
prop_assert_eq!(eval_relation_op(RelationOp::LT, l.into(), r.into()), l < r);
prop_assert_eq!(eval_relation_op(RelationOp::GE, l.into(), r.into()), l >= r);
prop_assert_eq!(eval_relation_op(RelationOp::LE, l.into(), r.into()), l <= r);
prop_assert_eq!(eval_relation_op(RelationOp::Gt, l.into(), r.into()), l > r);
prop_assert_eq!(eval_relation_op(RelationOp::Lt, l.into(), r.into()), l < r);
prop_assert_eq!(eval_relation_op(RelationOp::Ge, l.into(), r.into()), l >= r);
prop_assert_eq!(eval_relation_op(RelationOp::Le, l.into(), r.into()), l <= r);
}

#[test]
Expand All @@ -440,10 +440,10 @@ mod tests {
prop_assert_eq!(eval_num_op::<i16>(ArithOp::Max, l.into(), r.into()).unwrap(), l.max(r));
prop_assert_eq!(eval_num_op::<i16>(ArithOp::Min, l.into(), r.into()).unwrap(), l.min(r));

prop_assert_eq!(eval_relation_op(RelationOp::GT, l.into(), r.into()), l > r);
prop_assert_eq!(eval_relation_op(RelationOp::LT, l.into(), r.into()), l < r);
prop_assert_eq!(eval_relation_op(RelationOp::GE, l.into(), r.into()), l >= r);
prop_assert_eq!(eval_relation_op(RelationOp::LE, l.into(), r.into()), l <= r);
prop_assert_eq!(eval_relation_op(RelationOp::Gt, l.into(), r.into()), l > r);
prop_assert_eq!(eval_relation_op(RelationOp::Lt, l.into(), r.into()), l < r);
prop_assert_eq!(eval_relation_op(RelationOp::Ge, l.into(), r.into()), l >= r);
prop_assert_eq!(eval_relation_op(RelationOp::Le, l.into(), r.into()), l <= r);
}

#[test]
Expand All @@ -455,10 +455,10 @@ mod tests {
prop_assert_eq!(eval_num_op::<i8>(ArithOp::Max, l.into(), r.into()).unwrap(), l.max(r));
prop_assert_eq!(eval_num_op::<i8>(ArithOp::Min, l.into(), r.into()).unwrap(), l.min(r));

prop_assert_eq!(eval_relation_op(RelationOp::GT, l.into(), r.into()), l > r);
prop_assert_eq!(eval_relation_op(RelationOp::LT, l.into(), r.into()), l < r);
prop_assert_eq!(eval_relation_op(RelationOp::GE, l.into(), r.into()), l >= r);
prop_assert_eq!(eval_relation_op(RelationOp::LE, l.into(), r.into()), l <= r);
prop_assert_eq!(eval_relation_op(RelationOp::Gt, l.into(), r.into()), l > r);
prop_assert_eq!(eval_relation_op(RelationOp::Lt, l.into(), r.into()), l < r);
prop_assert_eq!(eval_relation_op(RelationOp::Ge, l.into(), r.into()), l >= r);
prop_assert_eq!(eval_relation_op(RelationOp::Le, l.into(), r.into()), l <= r);
}

#[test]
Expand All @@ -473,10 +473,10 @@ mod tests {
r.clone().into()).unwrap(), l.clone().max(r.clone()));
prop_assert_eq!(eval_num_op::<BigInt>(ArithOp::Min, l.clone().into(),
r.clone().into()).unwrap(), l.clone().min(r.clone()));
prop_assert_eq!(eval_relation_op(RelationOp::GT, l.clone().into(), r.clone().into()), l > r);
prop_assert_eq!(eval_relation_op(RelationOp::LT, l.clone().into(), r.clone().into()), l < r);
prop_assert_eq!(eval_relation_op(RelationOp::GE, l.clone().into(), r.clone().into()), l >= r);
prop_assert_eq!(eval_relation_op(RelationOp::LE, l.clone().into(), r.clone().into()), l <= r);
prop_assert_eq!(eval_relation_op(RelationOp::Gt, l.clone().into(), r.clone().into()), l > r);
prop_assert_eq!(eval_relation_op(RelationOp::Lt, l.clone().into(), r.clone().into()), l < r);
prop_assert_eq!(eval_relation_op(RelationOp::Ge, l.clone().into(), r.clone().into()), l >= r);
prop_assert_eq!(eval_relation_op(RelationOp::Le, l.clone().into(), r.clone().into()), l <= r);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion ergotree-interpreter/src/eval/coll_exists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod tests {

fn check(coll: Vec<i32>) {
let body: Expr = BinOp {
kind: RelationOp::LE.into(),
kind: RelationOp::Le.into(),
left: Box::new(Expr::Const(1i32.into())),
right: Box::new(
ValUse {
Expand Down
2 changes: 1 addition & 1 deletion ergotree-interpreter/src/eval/coll_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mod tests {
}
.into();
let body: Expr = BinOp {
kind: RelationOp::LE.into(),
kind: RelationOp::Le.into(),
left: Box::new(Expr::Const(1i64.into())),
right: Box::new(Expr::ExtractAmount(
ExtractAmount::new(val_use)
Expand Down
2 changes: 1 addition & 1 deletion ergotree-interpreter/src/eval/coll_forall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod tests {

fn check(coll: Vec<i32>) {
let body: Expr = BinOp {
kind: RelationOp::LE.into(),
kind: RelationOp::Le.into(),
left: Box::new(Expr::Const(1i32.into())),
right: Box::new(
ValUse {
Expand Down
4 changes: 2 additions & 2 deletions ergotree-interpreter/src/sigma_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ pub enum FirstProverMessage {
/// Discrete log
FirstDlogProverMessage(FirstDlogProverMessage),
/// DH tupl
FirstDHTProverMessage,
FirstDhtProverMessage,
}

impl ProverMessage for FirstProverMessage {
fn bytes(&self) -> Vec<u8> {
match self {
FirstProverMessage::FirstDlogProverMessage(fdpm) => fdpm.bytes(),
FirstProverMessage::FirstDHTProverMessage => todo!(),
FirstProverMessage::FirstDhtProverMessage => todo!(),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions ergotree-interpreter/src/sigma_protocol/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ fn convert_to_unproven(ergo_lib: SigmaBoolean) -> UnprovenTree {
// TODO: why it's even here? Make another SigmaBoolean without trivial props?
SigmaBoolean::TrivialProp(_) => todo!(),
SigmaBoolean::ProofOfKnowledge(pok) => match pok {
SigmaProofOfKnowledgeTree::ProveDHTuple(_) => todo!(),
SigmaProofOfKnowledgeTree::ProveDhTuple(_) => todo!(),
SigmaProofOfKnowledgeTree::ProveDlog(prove_dlog) => UnprovenSchnorr {
proposition: prove_dlog,
commitment_opt: None,
Expand All @@ -285,7 +285,7 @@ fn convert_to_unproven(ergo_lib: SigmaBoolean) -> UnprovenTree {
}
.into(),
},
SigmaBoolean::CAND(_) => todo!(),
SigmaBoolean::Cand(_) => todo!(),
}
}

Expand Down
28 changes: 14 additions & 14 deletions ergotree-ir/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use thiserror::Error;
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum Address {
/// serialized (compressed) public key
P2PK(ProveDlog),
P2Pk(ProveDlog),
/// serialized script
P2S(Vec<u8>),
// P2SH([u8; 24]),
Expand All @@ -73,7 +73,7 @@ impl Address {
pub fn p2pk_from_pk_bytes(bytes: &[u8]) -> Result<Address, SerializationError> {
EcPoint::sigma_parse_bytes(bytes.to_vec())
.map(ProveDlog::from)
.map(Address::P2PK)
.map(Address::P2Pk)
}

/// Re-create the address from ErgoTree that was built from the address
Expand All @@ -88,7 +88,7 @@ impl Address {
tpe: SType::SSigmaProp,
v,
}) => ProveDlog::try_from(v.clone())
.map(Address::P2PK)
.map(Address::P2Pk)
.unwrap_or_else(|_| Address::P2S(tree.sigma_serialize_bytes())),
_ => Address::P2S(tree.sigma_serialize_bytes()),
}),
Expand All @@ -99,7 +99,7 @@ impl Address {
/// address type prefix (for encoding)
pub fn address_type_prefix(&self) -> AddressTypePrefix {
match self {
Address::P2PK(_) => AddressTypePrefix::P2PK,
Address::P2Pk(_) => AddressTypePrefix::P2Pk,
Address::P2S(_) => AddressTypePrefix::Pay2S,
//Address::P2SH(_) => AddressTypePrefix::P2SH,
}
Expand All @@ -108,15 +108,15 @@ impl Address {
/// byte array
pub fn content_bytes(&self) -> Vec<u8> {
match self {
Address::P2PK(prove_dlog) => prove_dlog.h.sigma_serialize_bytes(),
Address::P2Pk(prove_dlog) => prove_dlog.h.sigma_serialize_bytes(),
Address::P2S(bytes) => bytes.clone(),
}
}

/// script encoded in the address
pub fn script(&self) -> Result<ErgoTree, SerializationError> {
match self {
Address::P2PK(prove_dlog) => Ok(ErgoTree::from(Expr::Const(
Address::P2Pk(prove_dlog) => Ok(ErgoTree::from(Expr::Const(
SigmaProp::new(SigmaBoolean::ProofOfKnowledge(
SigmaProofOfKnowledgeTree::ProveDlog(prove_dlog.clone()),
))
Expand Down Expand Up @@ -174,9 +174,9 @@ pub enum AddressError {
/// Address types
pub enum AddressTypePrefix {
/// 0x01 - Pay-to-PublicKey(P2PK) address
P2PK = 1,
P2Pk = 1,
/// 0x02 - Pay-to-Script-Hash(P2SH)
Pay2SH = 2,
Pay2Sh = 2,
/// 0x03 - Pay-to-Script(P2S)
Pay2S = 3,
}
Expand All @@ -185,8 +185,8 @@ impl TryFrom<u8> for AddressTypePrefix {
type Error = AddressEncoderError;
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
v if v == AddressTypePrefix::P2PK as u8 => Ok(AddressTypePrefix::P2PK),
v if v == AddressTypePrefix::Pay2SH as u8 => Ok(AddressTypePrefix::Pay2SH),
v if v == AddressTypePrefix::P2Pk as u8 => Ok(AddressTypePrefix::P2Pk),
v if v == AddressTypePrefix::Pay2Sh as u8 => Ok(AddressTypePrefix::Pay2Sh),
v if v == AddressTypePrefix::Pay2S as u8 => Ok(AddressTypePrefix::Pay2S),
v => Err(AddressEncoderError::InvalidAddressType(v)),
}
Expand Down Expand Up @@ -360,11 +360,11 @@ impl AddressEncoder {
let content_bytes: Vec<u8> = without_checksum[1..].to_vec(); // without head_byte
let address_type = AddressTypePrefix::try_from(bytes[0] & 0xF_u8)?;
Ok(match address_type {
AddressTypePrefix::P2PK => {
Address::P2PK(ProveDlog::new(EcPoint::sigma_parse_bytes(content_bytes)?))
AddressTypePrefix::P2Pk => {
Address::P2Pk(ProveDlog::new(EcPoint::sigma_parse_bytes(content_bytes)?))
}
AddressTypePrefix::Pay2S => Address::P2S(content_bytes),
AddressTypePrefix::Pay2SH => todo!(),
AddressTypePrefix::Pay2Sh => todo!(),
})
}

Expand Down Expand Up @@ -407,7 +407,7 @@ pub(crate) mod arbitrary {
let non_parseable_tree = "100204a00b08cd021dde34603426402615658f1d970cfa7c7bd92ac81a8b16eeebff264d59ce4604ea02d192a39a8cc7a70173007301";
prop_oneof![
any::<ErgoTree>().prop_map(|t| match ProveDlog::try_from(t.clone()) {
Ok(dlog) => Address::P2PK(dlog),
Ok(dlog) => Address::P2Pk(dlog),
Err(_) => Address::P2S(t.sigma_serialize_bytes()),
}),
Just(Address::P2S(base16::decode(non_parseable_tree).unwrap()))
Expand Down
16 changes: 8 additions & 8 deletions ergotree-ir/src/mir/bin_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ pub enum RelationOp {
/// Non-equality
NEq,
/// Greater of equal
GE,
Ge,
/// Greater than..
GT,
Gt,
/// Less or equal
LE,
Le,
/// Less then
LT,
Lt,
/// Logical AND
And,
/// Logical OR
Expand All @@ -68,10 +68,10 @@ impl From<RelationOp> for OpCode {
match op {
RelationOp::Eq => OpCode::EQ,
RelationOp::NEq => OpCode::NEQ,
RelationOp::GE => OpCode::GE,
RelationOp::GT => OpCode::GT,
RelationOp::LE => OpCode::LE,
RelationOp::LT => OpCode::LT,
RelationOp::Ge => OpCode::GE,
RelationOp::Gt => OpCode::GT,
RelationOp::Le => OpCode::LE,
RelationOp::Lt => OpCode::LT,
RelationOp::And => OpCode::BIN_AND,
RelationOp::Or => OpCode::BIN_OR,
}
Expand Down
8 changes: 4 additions & 4 deletions ergotree-ir/src/serialization/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ impl SigmaSerializable for Expr {
OpCode::LOGICAL_NOT => Ok(LogicalNot::sigma_parse(r)?.into()),
OpCode::BIN_AND => Ok(bin_op_sigma_parse(RelationOp::And.into(), r)?),
OpCode::BIN_OR => Ok(bin_op_sigma_parse(RelationOp::Or.into(), r)?),
OpCode::GT => Ok(bin_op_sigma_parse(RelationOp::GT.into(), r)?),
OpCode::LT => Ok(bin_op_sigma_parse(RelationOp::LT.into(), r)?),
OpCode::GE => Ok(bin_op_sigma_parse(RelationOp::GE.into(), r)?),
OpCode::LE => Ok(bin_op_sigma_parse(RelationOp::LE.into(), r)?),
OpCode::GT => Ok(bin_op_sigma_parse(RelationOp::Gt.into(), r)?),
OpCode::LT => Ok(bin_op_sigma_parse(RelationOp::Lt.into(), r)?),
OpCode::GE => Ok(bin_op_sigma_parse(RelationOp::Ge.into(), r)?),
OpCode::LE => Ok(bin_op_sigma_parse(RelationOp::Le.into(), r)?),
OpCode::PLUS => Ok(bin_op_sigma_parse(ArithOp::Plus.into(), r)?),
OpCode::MINUS => Ok(bin_op_sigma_parse(ArithOp::Minus.into(), r)?),
OpCode::MULTIPLY => Ok(bin_op_sigma_parse(ArithOp::Multiply.into(), r)?),
Expand Down
4 changes: 2 additions & 2 deletions ergotree-ir/src/serialization/sigmaboolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ impl SigmaSerializable for SigmaBoolean {
self.op_code().sigma_serialize(w)?;
match self {
SigmaBoolean::ProofOfKnowledge(proof) => match proof {
SigmaProofOfKnowledgeTree::ProveDHTuple { .. } => todo!(),
SigmaProofOfKnowledgeTree::ProveDhTuple { .. } => todo!(),
SigmaProofOfKnowledgeTree::ProveDlog(v) => v.sigma_serialize(w),
},
SigmaBoolean::CAND(_) => todo!(),
SigmaBoolean::Cand(_) => todo!(),
SigmaBoolean::TrivialProp(_) => Ok(()), // besides opCode no additional bytes
}
}
Expand Down
6 changes: 3 additions & 3 deletions ergotree-ir/src/sigma_protocol/sigma_boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl From<EcPoint> for ProveDlog {
/// Construct a new SigmaProp value representing public key of Diffie Hellman signature protocol.
/// Common input: (g,h,u,v)
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct ProveDHTuple {
pub struct ProveDhTuple {
gv: Box<EcPoint>,
hv: Box<EcPoint>,
uv: Box<EcPoint>,
Expand All @@ -49,7 +49,7 @@ pub struct ProveDHTuple {
#[derive(PartialEq, Eq, Debug, Clone, From)]
pub enum SigmaProofOfKnowledgeTree {
/// public key of Diffie Hellman signature protocol
ProveDHTuple(ProveDHTuple),
ProveDhTuple(ProveDhTuple),
/// public key of discrete logarithm signature protocol
ProveDlog(ProveDlog),
}
Expand All @@ -63,7 +63,7 @@ pub enum SigmaBoolean {
/// Sigma proposition
ProofOfKnowledge(SigmaProofOfKnowledgeTree),
/// AND conjunction for sigma propositions
CAND(Vec<SigmaBoolean>),
Cand(Vec<SigmaBoolean>),
}

impl SigmaBoolean {
Expand Down

0 comments on commit 30be67d

Please sign in to comment.