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

Conversation

chris-wood
Copy link
Contributor

@chris-wood chris-wood commented Jun 13, 2023

See the specification for more information. This is needed to help experiment with a version of Privacy Pass that supports public metadata, described here.

This change removes some of the interfaces that were previously unused, like the generic blindsign.Verifier and BlindSign.Signer interfaces.

cc @Guss123

@chris-wood chris-wood requested a review from armfazh June 13, 2023 18:43
blindsign/blindrsa/rsa.go Outdated Show resolved Hide resolved
@bwesterb
Copy link
Member

bwesterb commented Jun 14, 2023

This breaks the old API. In particular, it will break this online example. Do we need to break it?

Copy link
Contributor

@armfazh armfazh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did one pass, will do another one once the suggested changes are addressed.

blindsign/blindsign.go Show resolved Hide resolved
blindsign/blindrsa/brsa.go Show resolved Hide resolved
blindsign/blindrsa/format_test_vectors.py Outdated Show resolved Hide resolved
@chris-wood
Copy link
Contributor Author

This breaks the old API. In particular, it will break this online example. Do we need to break it?

I suppose not, but I don't think we need to worry about API stability for a library like this.

@chris-wood
Copy link
Contributor Author

@bwesterb @armfazh most specific changes have been addressed, but we have open the API compatibility question and stuff about naming.

Copy link
Contributor

@armfazh armfazh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with refactoring the code (and breaking API) if it improves the code. So, here is my suggestion.

The package blindrsa already indicates it is a blind signature of RSA type. So we can remove some prefixes.

BRSASigner -> Signer
BRSAVerifier -> Verifier
BRSAVerifierState -> VerifierState

Make the following types unexported since there exist New<> functions for them:

DeterminsiticBRSAVerifier -> determinsiticBRSAVerifier
RandomBRSAVerifier -> randomBRSAVerifier
BigPrivateKey -> bigPrivateKey
BigPublicKey -> bigPublicKey 

Coalesce NewBRSAVerifier and NewDeterministicBRSAVerifier in a single function NewVerifier(pk,hash,flag) Verifier with a boolean flag to choose whether is randomized or deterministic.

For Partially-blind RSA, my suggestion is to create a subpackage:

/circl/blindsign/blindrsa                   # blind RSA 
/circl/blindsign/blindrsa/partialblindrsa   # partial blind RSA 
/circl/blindsign/blindrsa/internal/         # common code

This ease the naming to have plain Signer, Verifier, etc. names.

blindsign/blindrsa/pbrsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/pbrsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/pbrsa.go Outdated Show resolved Hide resolved
@chris-wood
Copy link
Contributor Author

Thanks @armfazh -- I enacted all your suggestions except for the one to merge constructors. I think it's better to avoid constructors with boolean flags. For the other comments regarding key generation and whatnot, we could implement that in this change or separately. Do you have a preference?

Copy link
Contributor

@armfazh armfazh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding some comments to blindrsa, still need to review partialblind

blindsign/blindrsa/brsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/brsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/common.go Outdated Show resolved Hide resolved
blindsign/blindrsa/pbrsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/brsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/brsa.go Show resolved Hide resolved
blindsign/blindrsa/brsa.go Show resolved Hide resolved
chris-wood and others added 2 commits June 15, 2023 12:34
Co-authored-by: Armando Faz <armfazh@users.noreply.github.com>
Co-authored-by: Armando Faz <armfazh@users.noreply.github.com>
chris-wood and others added 3 commits June 15, 2023 12:34
Co-authored-by: Armando Faz <armfazh@users.noreply.github.com>
}

// VerifyMessageSignature verifies the input message signature against the expected public key
func VerifyMessageSignature(message, signature []byte, saltLength int, pk *keys.BigPublicKey, hash crypto.Hash) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are some exported functions that require keys from /internal/keys package, which is an internal package.
Thus, these keys cannot be instantiated in other packages (unless providing a generator function).

Can we reconsider to unexport, for example, VerifyMessageSignature, since we already have two constructors to get a Verifier?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reconsider to unexport, for example, VerifyMessageSignature, since we already have two constructors to get a Verifier?

I'm not sure I follow this. Can you rephrase?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently there are three methods to verify a signature:

  1. building a NewVerifier, and calling its Verify method.
  2. building a NewDeterministicVerifier, and calling its Verify method.
  3. using the VerifyMessageSignature function.

I see redundancy on having so many functions that do the same thing (unless they behave differently).
It seems to me that 3) should not be exposed and moved to an internal package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it -- thanks for clarifying. VerifyMessageSignature is what's called internally for the Verify function of both NewVerifier and NewDeterminsiticVerifier.

Copy link
Contributor

@armfazh armfazh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few minor changes only, otherwise lgtm

blindsign/blindrsa/partiallyblindrsa/pbrsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/partiallyblindrsa/pbrsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/partiallyblindrsa/pbrsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/partiallyblindrsa/pbrsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/partiallyblindrsa/pbrsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/partiallyblindrsa/pbrsa.go Outdated Show resolved Hide resolved
blindsign/blindrsa/common.go Outdated Show resolved Hide resolved
@armfazh armfazh added changesAPI PR changes the API of a package new feature New functionality or module labels Jun 15, 2023
chris-wood and others added 6 commits June 15, 2023 14:09
Co-authored-by: Armando Faz <armfazh@users.noreply.github.com>
Co-authored-by: Armando Faz <armfazh@users.noreply.github.com>
Co-authored-by: Armando Faz <armfazh@users.noreply.github.com>
Co-authored-by: Armando Faz <armfazh@users.noreply.github.com>
Co-authored-by: Armando Faz <armfazh@users.noreply.github.com>
@chris-wood
Copy link
Contributor Author

@armfazh thanks again for the suggestions -- I applied them.

chris-wood and others added 4 commits June 15, 2023 14:22
@chris-wood
Copy link
Contributor Author

Thanks for the changes @armfazh!

@chris-wood chris-wood merged commit afe0bef into cloudflare:main Jul 6, 2023
10 checks passed
jooola pushed a commit to hetznercloud/terraform-provider-hcloud that referenced this pull request Jan 9, 2024
…834)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [github.com/cloudflare/circl](https://togithub.com/cloudflare/circl) |
`v1.3.3` -> `v1.3.7` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fcloudflare%2fcircl/v1.3.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fcloudflare%2fcircl/v1.3.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fcloudflare%2fcircl/v1.3.3/v1.3.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fcloudflare%2fcircl/v1.3.3/v1.3.7?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

### GitHub Vulnerability Alerts

####
[GHSA-9763-4f94-gfch](https://togithub.com/cloudflare/circl/security/advisories/GHSA-9763-4f94-gfch)

### Impact
On some platforms, when an attacker can time decapsulation of Kyber on
forged cipher texts, they could possibly learn (parts of) the secret
key.

Does not apply to ephemeral usage, such as when used in the regular way
in TLS.

### Patches
Patched in 1.3.7.

### References
- [kyberslash.cr.yp.to](https://kyberslash.cr.yp.to/)

---

### Release Notes

<details>
<summary>cloudflare/circl (github.com/cloudflare/circl)</summary>

###
[`v1.3.7`](https://togithub.com/cloudflare/circl/releases/tag/v1.3.7):
CIRCL v1.3.7

[Compare
Source](https://togithub.com/cloudflare/circl/compare/v1.3.6...v1.3.7)

#### CIRCL v1.3.7

##### What's Changed

- build(deps): bump golang.org/x/crypto from
0.3.1-0.20221117191849-2c476679df9a to 0.17.0 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[cloudflare/circl#467
- kyber: remove division by q in ciphertext compression by
[@&#8203;bwesterb](https://togithub.com/bwesterb) in
[cloudflare/circl#468
- Releasing CIRCL v1.3.7 by
[@&#8203;armfazh](https://togithub.com/armfazh) in
[cloudflare/circl#469

##### New Contributors

- [@&#8203;dependabot](https://togithub.com/dependabot) made their first
contribution in
[cloudflare/circl#467

**Full Changelog**:
cloudflare/circl@v1.3.6...v1.3.7

###
[`v1.3.6`](https://togithub.com/cloudflare/circl/releases/tag/v1.3.6):
CIRCL v1.3.6

[Compare
Source](https://togithub.com/cloudflare/circl/compare/v1.3.5...v1.3.6)

#### CIRCL v1.3.6

##### What's Changed

- internal: add TurboShake{128,256} by
[@&#8203;bwesterb](https://togithub.com/bwesterb) in
[cloudflare/circl#430
- Kangaroo12 draft -10 by
[@&#8203;bwesterb](https://togithub.com/bwesterb) in
[cloudflare/circl#431
- Add K12 as XOF by [@&#8203;bwesterb](https://togithub.com/bwesterb) in
[cloudflare/circl#437
- xof/k12: Fix a typo in the package documentation by
[@&#8203;cjpatton](https://togithub.com/cjpatton) in
[cloudflare/circl#438
- Set CIRCL version for generated assembler code. by
[@&#8203;armfazh](https://togithub.com/armfazh) in
[cloudflare/circl#440
- Add tkn20 benchmarks by
[@&#8203;tanyav2](https://togithub.com/tanyav2) in
[cloudflare/circl#442
- Add partially blind RSA implementation by
[@&#8203;chris-wood](https://togithub.com/chris-wood) in
[cloudflare/circl#445
- Update doc.go by
[@&#8203;nadimkobeissi](https://togithub.com/nadimkobeissi) in
[cloudflare/circl#447
- tss/rsa: key generation for threshold RSA (safe primes) by
[@&#8203;armfazh](https://togithub.com/armfazh) in
[cloudflare/circl#450
- Bumping Go version for CI jobs. by
[@&#8203;armfazh](https://togithub.com/armfazh) in
[cloudflare/circl#457
- Spelling by [@&#8203;jsoref](https://togithub.com/jsoref) in
[cloudflare/circl#456
- blindrsa: updating blindrsa to be compliant with RFC9474 by
[@&#8203;armfazh](https://togithub.com/armfazh) in
[cloudflare/circl#464
- Releasing CIRCL v1.3.6 by
[@&#8203;armfazh](https://togithub.com/armfazh) in
[cloudflare/circl#465

##### New Contributors

- [@&#8203;nadimkobeissi](https://togithub.com/nadimkobeissi) made their
first contribution in
[cloudflare/circl#447
- [@&#8203;jsoref](https://togithub.com/jsoref) made their first
contribution in
[cloudflare/circl#456

**Full Changelog**:
cloudflare/circl@v1.3.3...v1.3.6

###
[`v1.3.5`](https://togithub.com/cloudflare/circl/compare/v1.3.4...v1.3.5)

[Compare
Source](https://togithub.com/cloudflare/circl/compare/v1.3.4...v1.3.5)

###
[`v1.3.4`](https://togithub.com/cloudflare/circl/compare/v1.3.3...v1.3.4)

[Compare
Source](https://togithub.com/cloudflare/circl/compare/v1.3.3...v1.3.4)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "" (UTC), Automerge - At any time (no
schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/hetznercloud/terraform-provider-hcloud).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjcuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyNy4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changesAPI PR changes the API of a package new feature New functionality or module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants