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

Extend package API with features usefule for existing apps #479

Merged
merged 4 commits into from
Aug 4, 2023

Conversation

cthulhu-rider
Copy link
Contributor

@cthulhu-rider cthulhu-rider commented Jul 29, 2023

Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

OK otherwise.

user/signer.go Outdated Show resolved Hide resolved
crypto/signature.go Outdated Show resolved Hide resolved
@cthulhu-rider cthulhu-rider force-pushed the feature/new-methods branch 2 times, most recently from 3ba061e to b99e489 Compare August 3, 2023 06:38
@cthulhu-rider cthulhu-rider marked this pull request as ready for review August 3, 2023 07:07
user/signer.go Outdated
return s.id
// NewStaticSignerWithID creates new [Signer] with specified [ID].
func NewStaticSignerWithID(scheme neofscrypto.Scheme, sig []byte, pubKey neofscrypto.PublicKey, id ID) Signer {
return NewSigner(neofscrypto.NewStaticSigner(scheme, sig, pubKey), id)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@smallhive
having NewSigner and neofscrypto.NewStaticSigner: do we really need NewStaticSignerWithID then?

Copy link
Contributor

Choose a reason for hiding this comment

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

We have both variants for the usual signer in case if someone wants to set a different user.ID. I think we should save this flexibility here, as a minimum for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

save this flexibility here

to keep or not to keep NewStaticSignerWithID?

it may be

s := user.NewStaticSignerWithID(scheme, sig, pub, id)
// or
s := user.NewSigner(neofscrypto.NewStaticSigner(scheme, sig, pub), id)

does first approach worth a separate function?

Copy link
Contributor

Choose a reason for hiding this comment

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

The second option covers my requirements, you may remove NewStaticSignerWithID or mark it obsolete

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, lets try to ride w/o it (we can always add if that)

@cthulhu-rider cthulhu-rider force-pushed the feature/new-methods branch 2 times, most recently from 1e1ae8f to 480b739 Compare August 3, 2023 11:54
Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

All of the other changes are perfectly fine.

crypto/signature.go Outdated Show resolved Hide resolved
Provide getters of signature scheme, public key and value. Make
`WriteToV2` method to decode public key from binary to assert scheme
format.

New API will allow to avoid `WriteToV2` calls in user space. New unit
test checks and shows client-to-server transport over NeoFS API V2
protocol.

Signed-off-by: Leonard Lyubich <[email protected]>
Encoding methods of `PublicKey` interface require buffer pre-allocation.
In cases where the user does not have a buffer prepared in advance, he
has to explicitly create it and encode the key. Helper function
`PublicKeyBytes` is added to make code easier.

Signed-off-by: Leonard Lyubich <[email protected]>
Previously, package provided constructors for `Signer` instances with
RFC 6979 signature scheme only. User may need to construct any `Signer`
instance (other scheme or even custom implementation).

Add generic constructor `NewSigner` accepting split `neofscrypto.Signer`
and `user.ID`. Add two constructors from standard `ecdsa.PrivateKey`
with an explanation that the user ID is resolved automatically.

Signed-off-by: Leonard Lyubich <[email protected]>
Signature is used for user authentication so access to public key is
required. Digital signature bytes may still be unexported because they
are only useful for `VerifySignature` method.

Add `IssuerPublicKeyBytes` method returning binary-encoded public key of
the session issuer.

Signed-off-by: Leonard Lyubich <[email protected]>
@roman-khimov roman-khimov merged commit cfc9fac into nspcc-dev:master Aug 4, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants