diff options
Diffstat (limited to 'nizk/commit.go')
-rw-r--r-- | nizk/commit.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/nizk/commit.go b/nizk/commit.go index 93c730f..27e31f7 100644 --- a/nizk/commit.go +++ b/nizk/commit.go @@ -55,6 +55,18 @@ func NewBitFromScalars(id Bytes, set bool, α, β *Scalar) *Bit { return b } +func Int2Bits(id Bytes, val int, bitlength int) []*Bit { + if bitlength < 0 || bitlength > 24 { + return nil + } + + bits := make([]*Bit, bitlength) + for i := range bitlength { + bits[i] = NewBit(id, (val>>(bitlength-i-1))&1 != 0) + } + return bits +} + func (b *Bit) IsSet() bool { return b.set } |