o1egl / paseto

Platform-Agnostic Security Tokens implementation in GO (Golang)
MIT License
852 stars 34 forks source link

Assymetric woes #26

Closed delaneyj closed 2 years ago

delaneyj commented 4 years ago

Symmetric/local keys work great, however...

        v2 := paseto.NewV2()
    _, privateKey, err := ed25519.GenerateKey(nil)

    jsonToken := paseto.JSONToken{
        Expiration: time.Now().Add(24 * time.Hour),
        Subject:    "Foo",
        Audience:   "Bar",
        Issuer:     "This guy",
        IssuedAt:   time.Now(),
    }

    // Add custom claim    to the token
    jsonToken.Set("data", "this is a signed message")
    footer := "some footer"

    // Sign data
    token, err := v2.Sign(privateKey, &jsonToken, &footer)

Gives a err of incorrect private key type. What am I doing wrong here?

delaneyj commented 4 years ago

Also confirmed on go playground

delaneyj commented 4 years ago

Looks like it stems from golang.org/x/crypto/ed25519 now being in stdlib as crypto/ed25519

o1egl commented 4 years ago

You are right. crypto/ed25519 is added to stdlib in the resent version of go. As a temporary solution you can just import golang.org/x/crypto/ed25519 instead of crypto/ed25519.

shahriar350 commented 2 years ago

how can i parse data for this v2

o1egl commented 2 years ago

@shahriar350 check out the docs

shahriar350 commented 2 years ago

@shahriar350 check out the docs

thank you so much.