Skip to content

Commit 667d9f3

Browse files
committed
re-order steps of verification
1 parent 0aabcc4 commit 667d9f3

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/verify.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ pub trait ContractVerify<SealDef: RgbSealDef>: ContractApi<SealDef> {
116116
closed_seals.push(seal);
117117
}
118118

119+
// We need to check that all seal definitions strictly match operation-defined destructible cells
120+
let defined = header
121+
.operation
122+
.destructible
123+
.iter()
124+
.map(|cell| cell.auth.to_byte_array())
125+
.collect::<BTreeSet<_>>();
126+
let sealed = header
127+
.defined_seals
128+
.values()
129+
.map(|seal| seal.auth_token().to_byte_array())
130+
.collect::<BTreeSet<_>>();
131+
// It is a subset and not equal set since some of the seals might be unknown to us: we know their
132+
// commitment auth token, but do not know definition.
133+
if !sealed.is_subset(&defined) {
134+
return Err(VerificationError::SealsDefinitionMismatch(opid));
135+
}
136+
119137
// This convoluted logic happens since we use a state machine which ensures the client can't lie to
120138
// the verifier
121139
let mut witness_count = 0usize;
@@ -148,24 +166,6 @@ pub trait ContractVerify<SealDef: RgbSealDef>: ContractApi<SealDef> {
148166
witness_count += 1;
149167
}
150168

151-
// We need to check that all seal definitions strictly match operation-defined destructible cells
152-
let defined = header
153-
.operation
154-
.destructible
155-
.iter()
156-
.map(|cell| cell.auth.to_byte_array())
157-
.collect::<BTreeSet<_>>();
158-
let sealed = header
159-
.defined_seals
160-
.values()
161-
.map(|seal| seal.auth_token().to_byte_array())
162-
.collect::<BTreeSet<_>>();
163-
// It is a subset and not equal set since some of the seals might be unknown to us: we know their
164-
// commitment auth token, but do not know definition.
165-
if !sealed.is_subset(&defined) {
166-
return Err(VerificationError::SealsDefinitionMismatch(opid));
167-
}
168-
169169
if !closed_seals.is_empty() && witness_count == 0 {
170170
return Err(VerificationError::NoWitness(opid));
171171
}

0 commit comments

Comments
 (0)