LordXido commited on
Commit
ca43859
·
verified ·
1 Parent(s): 6510ff3

Create src/verifier.rs

Browse files
Files changed (1) hide show
  1. src/verifier.rs +19 -0
src/verifier.rs ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ use crate::opcode::Opcode;
2
+
3
+ pub fn verify_program(bytes: &[u8]) -> Result<(), String> {
4
+ for chunk in bytes.chunks(8) {
5
+ let opcode = Opcode::from_byte(chunk[0])
6
+ .ok_or("Unknown opcode")?;
7
+
8
+ // Forbidden opcodes (constitution)
9
+ if (0xE0..=0xE5).contains(&(chunk[0])) {
10
+ return Err("Constitutional violation".into());
11
+ }
12
+
13
+ // Hard invariants
14
+ if opcode == Opcode::CISS && chunk[5] == 0 {
15
+ return Err("Zero credit issuance forbidden".into());
16
+ }
17
+ }
18
+ Ok(())
19
+ }