diff options
author | Özgür Kesim <oec@codeblau.de> | 2024-11-15 19:30:11 +0100 |
---|---|---|
committer | Özgür Kesim <oec@codeblau.de> | 2024-11-15 19:30:11 +0100 |
commit | 9dbeb486bae03555c0ebd8e30708ef1fb2132231 (patch) | |
tree | 8a18b5e650d3bfa4568f81331cd21419ea172109 /nizk/commit.go | |
parent | 0eab6394734540c31dad54ecfc691b790ea4550c (diff) |
randomized test and benchmark work!
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 } |