Skip to content

Commit

Permalink
Made suggested changes.
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Littley <[email protected]>
  • Loading branch information
cody-littley committed Nov 20, 2024
1 parent cc62eac commit 0372ee9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
12 changes: 7 additions & 5 deletions api/proto/relay/relay.proto
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ message GetChunksRequest {
// 1. the operator id
// 2. for each chunk request:
// a. if the chunk request is a request by index:
// i. the blob key
// ii. the start index
// iii. the end index
// i. a one byte ASCII representation of the character "i" (aka Ox69)
// ii. the blob key
// iii. the start index
// iv. the end index
// b. if the chunk request is a request by range:
// i. the blob key
// ii. each requested chunk index, in order
// i. a one byte ASCII representation of the character "r" (aka Ox72)
// ii. the blob key
// iii. each requested chunk index, in order
bytes operator_signature = 3;
}

Expand Down
1 change: 1 addition & 0 deletions relay/auth/authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ func (a *requestAuthenticator) isAuthenticationStillValid(now time.Time, address
}

// removeOldAuthentications removes any authentications that have expired.
// This method is not thread safe and should be called with the savedAuthLock held.
func (a *requestAuthenticator) removeOldAuthentications(now time.Time) {
index := 0
for ; index < len(a.authenticationTimeouts); index++ {
Expand Down
7 changes: 7 additions & 0 deletions relay/auth/request_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import (
"golang.org/x/crypto/sha3"
)

var (
iByte = []byte{0x69}
rByte = []byte{0x72}
)

// HashGetChunksRequest hashes the given GetChunksRequest.
func HashGetChunksRequest(request *pb.GetChunksRequest) []byte {

Expand All @@ -19,6 +24,7 @@ func HashGetChunksRequest(request *pb.GetChunksRequest) []byte {
for _, chunkRequest := range request.GetChunkRequests() {
if chunkRequest.GetByIndex() != nil {
getByIndex := chunkRequest.GetByIndex()
hasher.Write(iByte)
hasher.Write(getByIndex.BlobKey)
for _, index := range getByIndex.ChunkIndices {
indexBytes := make([]byte, 4)
Expand All @@ -27,6 +33,7 @@ func HashGetChunksRequest(request *pb.GetChunksRequest) []byte {
}
} else {
getByRange := chunkRequest.GetByRange()
hasher.Write(rByte)
hasher.Write(getByRange.BlobKey)

startBytes := make([]byte, 4)
Expand Down

0 comments on commit 0372ee9

Please sign in to comment.