Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add partially blind RSA implementation #445

Merged
merged 26 commits into from Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4ccf65b
Add partially blind RSA implementation
chris-wood Feb 7, 2023
8b4d397
Apply linter
chris-wood Jun 13, 2023
8d0cc8c
Drop internal PrepareRandom function and rename the type
chris-wood Jun 14, 2023
9e2733b
Remove a couple more dead things
chris-wood Jun 14, 2023
7ab7309
Address Bas comments
chris-wood Jun 14, 2023
dd6b980
Apply changes from code review
chris-wood Jun 14, 2023
00ed5cc
Shuffle around the package contents per Armando's feedback
chris-wood Jun 15, 2023
dc62169
Add safe prime check for the partially blind RSA constructor
chris-wood Jun 15, 2023
224ed1b
gofumptd
chris-wood Jun 15, 2023
9edeed1
Update blindsign/blindrsa/brsa.go
chris-wood Jun 15, 2023
1160ea5
Update blindsign/blindrsa/brsa.go
chris-wood Jun 15, 2023
2698bbc
Update blindsign/blindrsa/common.go
chris-wood Jun 15, 2023
192c90f
Armando's comments on brsa
chris-wood Jun 15, 2023
fca31fe
File perms
chris-wood Jun 15, 2023
5c2c660
Update blindsign/blindrsa/partiallyblindrsa/pbrsa.go
chris-wood Jun 15, 2023
ad8b544
Update blindsign/blindrsa/partiallyblindrsa/pbrsa.go
chris-wood Jun 15, 2023
5d09f22
Update blindsign/blindrsa/partiallyblindrsa/pbrsa.go
chris-wood Jun 15, 2023
dd59736
Update blindsign/blindrsa/partiallyblindrsa/pbrsa.go
chris-wood Jun 15, 2023
3f9ad52
Update blindsign/blindrsa/partiallyblindrsa/pbrsa.go
chris-wood Jun 15, 2023
02e0f5d
Final Armando pass
chris-wood Jun 15, 2023
cf4a29b
Update blindsign/blindrsa/partiallyblindrsa/pbrsa_test.go
chris-wood Jun 15, 2023
47393f1
Fix comment
chris-wood Jun 15, 2023
8653635
Refactoring to hide internals.
armfazh Jun 20, 2023
4d5ca64
Merge pull request #1 from armfazh/pull445
chris-wood Jun 20, 2023
4d19adb
Updates based on latest draft changes
chris-wood Jun 28, 2023
739263e
Add test vector verification
chris-wood Jun 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion blindsign/blindrsa/pbrsa.go
Expand Up @@ -209,7 +209,10 @@ func (v PBRSAVerifier) Blind(random io.Reader, message, metadata []byte) ([]byte

// Pick a random string rand of length 32 bytes
rand := make([]byte, 32)
random.Read(rand)
_, err = random.Read(rand)
chris-wood marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, PBRSAVerifierState{}, err
}

// M' = M || rand
msgPrime := append(rand, message...)
Expand Down
28 changes: 1 addition & 27 deletions blindsign/blindrsa/pbrsa_test.go
Expand Up @@ -4,13 +4,10 @@
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/hex"
"encoding/json"
"encoding/pem"
"fmt"
"io"
"io/ioutil"
"math/big"
"os"
"testing"
Expand All @@ -21,7 +18,7 @@
pbrsaTestVectorInEnvironmentKey = "PBRSA_TEST_VECTORS_IN"
)

func loadStrongRSAKey() (*rsa.PrivateKey, error) {

Check failure on line 21 in blindsign/blindrsa/pbrsa_test.go

View workflow job for this annotation

GitHub Actions / Go-1.19/amd64

loadStrongRSAKey - result 1 (error) is always nil (unparam)
// https://gist.github.com/chris-wood/b77536febb25a5a11af428afff77820a
pEnc := "dcd90af1be463632c0d5ea555256a20605af3db667475e190e3af12a34a3324c46a3094062c59fb4b249e0ee6afba8bee14e0276d126c99f4784b23009bf6168ff628ac1486e5ae8e23ce4d362889de4df63109cbd90ef93db5ae64372bfe1c55f832766f21e94ea3322eb2182f10a891546536ba907ad74b8d72469bea396f3"
qEnc := "f8ba5c89bd068f57234a3cf54a1c89d5b4cd0194f2633ca7c60b91a795a56fa8c8686c0e37b1c4498b851e3420d08bea29f71d195cfbd3671c6ddc49cf4c1db5b478231ea9d91377ffa98fe95685fca20ba4623212b2f2def4da5b281ed0100b651f6db32112e4017d831c0da668768afa7141d45bbc279f1e0f8735d74395b3"
Expand Down Expand Up @@ -131,7 +128,6 @@
}

type rawPBRSATestVector struct {
t *testing.T
privateKey *rsa.PrivateKey
message []byte
metadata []byte
Expand All @@ -148,28 +144,6 @@
return hex.EncodeToString(d)
}

func mustMarshalPrivateKey(key *rsa.PrivateKey) []byte {
der, err := x509.MarshalPKCS8PrivateKey(key)
if err != nil {
panic(err)
}

block := &pem.Block{
Type: "PRIVATE KEY",
Bytes: der,
}

return pem.EncodeToMemory(block)
}

func mustMarshalPublicKey(key *rsa.PublicKey) []byte {
enc, err := x509.MarshalPKIXPublicKey(key)
if err != nil {
panic(err)
}
return enc
}

func (tv rawPBRSATestVector) MarshalJSON() ([]byte, error) {
pEnc := mustHex(tv.privateKey.Primes[0].Bytes())
qEnc := mustHex(tv.privateKey.Primes[1].Bytes())
Expand Down Expand Up @@ -244,7 +218,7 @@
}

func TestPBRSAGenerateTestVector(t *testing.T) {
var testCases = []struct {

Check failure on line 221 in blindsign/blindrsa/pbrsa_test.go

View workflow job for this annotation

GitHub Actions / Go-1.19/amd64

File is not `gofumpt`-ed (gofumpt)
msg []byte
metadata []byte
}{
Expand Down Expand Up @@ -282,7 +256,7 @@

var outputFile string
if outputFile = os.Getenv(pbrsaTestVectorOutEnvironmentKey); len(outputFile) > 0 {
err := ioutil.WriteFile(outputFile, encoded, 0644)
err := os.WriteFile(outputFile, encoded, 0644)

Check failure on line 259 in blindsign/blindrsa/pbrsa_test.go

View workflow job for this annotation

GitHub Actions / Go-1.19/amd64

File is not `gofumpt`-ed (gofumpt)
if err != nil {
t.Fatalf("Error writing test vectors: %v", err)
}
Expand Down