MCPcopy Create free account
hub / github.com/BitVM/BitVM / add1

Method add1

bitvm/src/bigint/add.rs:67–92  ·  view source on GitHub ↗

add one

()

Source from the content-addressed store, hash-verified

65
66 /// add one
67 pub fn add1() -> Script {
68 script! {
69 OP_1ADD // a0 ... an
70 { 1 << LIMB_SIZE } // a0 ... an x
71 OP_SWAP // a0 ... x an
72 for _ in 0..Self::N_LIMBS-1 { // ... x a
73 OP_2DUP // ... x a x a
74 OP_EQUAL // ... x a 0/1
75 OP_TUCK // ... x 0/1 a 0/1
76 OP_IF OP_NOT OP_ENDIF // ... x 0/1 a/0
77 OP_TOALTSTACK // ... x 0/1
78 OP_ROT // .. x 0/1 a_{i-1}
79 OP_ADD // .. x a'
80 }
81 // x a0
82 OP_NIP // a0
83 { Self::HEAD_OFFSET } // a0 y
84 OP_OVER // a0 y a0
85 OP_EQUAL // a0 0/1
86 OP_IF OP_NOT OP_ENDIF // a/0
87
88 for _ in 0..Self::N_LIMBS - 1 {
89 OP_FROMALTSTACK
90 }
91 }
92 }
93
94 /// Double the BigInt on top of the stack
95 ///

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected