Skip to content

Commit

Permalink
Merge pull request #210 from RGB-WG/fix/eprint
Browse files Browse the repository at this point in the history
Remove bulletproofs warning, fail on serialization
  • Loading branch information
dr-orlovsky authored Feb 26, 2024
2 parents 52e9dcb + 83c25cc commit 99c5318
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/contract/fungible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl Default for NoiseDumb {
/// Range proofs must be used alongside [`PedersenCommitment`]s to ensure that
/// the value do not overflow on arithmetic operations with the commitments.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
#[derive(StrictType, StrictEncode, StrictDecode)]
#[derive(StrictType)]
#[strict_type(lib = LIB_NAME_RGB, tags = custom)]
#[cfg_attr(
feature = "serde",
Expand All @@ -458,6 +458,18 @@ impl Default for RangeProof {
fn default() -> Self { RangeProof::Placeholder(default!()) }
}

impl StrictEncode for RangeProof {
fn strict_encode<W: TypedWrite>(&self, _: W) -> io::Result<W> {
panic!("bulletproof dummies must never be stored")
}
}

impl StrictDecode for RangeProof {
fn strict_decode(_: &mut impl TypedRead) -> Result<Self, DecodeError> {
panic!("bulletproofs dummies must never be read")
}
}

pub struct PedersenProtocol;

impl CommitmentProtocol for PedersenProtocol {}
Expand Down Expand Up @@ -489,10 +501,6 @@ impl ConfidentialState for ConcealedValue {

impl CommitVerify<RevealedValue, PedersenProtocol> for ConcealedValue {
fn commit(revealed: &RevealedValue) -> Self {
eprintln!(
"Warning: current version of RGB Core doesn't support production of bulletproofs; \
thus, fungible state must be never kept concealed"
);
let commitment = PedersenCommitment::commit(revealed);
// TODO: Do actual conceal upon integration of bulletproofs library
let range_proof = RangeProof::default();
Expand All @@ -503,15 +511,6 @@ impl CommitVerify<RevealedValue, PedersenProtocol> for ConcealedValue {
}
}

impl ConcealedValue {
/// Verifies bulletproof against the commitment.
pub fn verify(&self) -> bool {
match self.range_proof {
RangeProof::Placeholder(_) => false,
}
}
}

/// Errors verifying range proofs.
#[derive(Copy, Clone, PartialEq, Eq, Debug, Display, Error)]
#[display(doc_comments)]
Expand All @@ -528,6 +527,7 @@ pub enum RangeProofError {
impl ConcealedValue {
/// Verifies validity of the range proof.
pub fn verify_range_proof(&self) -> Result<bool, RangeProofError> {
// We always fail here
Err(RangeProofError::BulletproofsAbsent)
}
}
Expand Down

0 comments on commit 99c5318

Please sign in to comment.