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

txnbuild: Fix manage data value in sep10 challenge #1569

Merged
merged 3 commits into from
Aug 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions txnbuild/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,14 @@ func BuildChallengeTx(serverSignerSecret, clientAccountID, anchorName, network s
return "", err
}

randomNonce, err := generateRandomNonce(64)
// SEP10 spec requires 48 byte cryptographic-quality random string
randomNonce, err := generateRandomNonce(48)
abuiles marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return "", err
}

if len(randomNonce) != 64 {
// Encode 48-byte nonce to base64 for a total of 64-bytes
randomNonceToString := base64.StdEncoding.EncodeToString(randomNonce)
if len(randomNonceToString) != 64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: I don't think we need this check here -- we already have an unit test.

return "", errors.New("64 byte long random nonce required")
}

Expand Down Expand Up @@ -248,7 +250,7 @@ func BuildChallengeTx(serverSignerSecret, clientAccountID, anchorName, network s
&ManageData{
SourceAccount: &ca,
Name: anchorName + " auth",
Value: randomNonce,
Value: []byte(randomNonceToString),
},
},
Timebounds: txTimebound,
Expand Down