Commit 911ef8b6 authored by David Van Cleve's avatar David Van Cleve Committed by Commit Bot

Add a struct representing a Trust Tokens key commitment.

This is a minimal change adding a struct representing a Trust Tokens
key commitment registry's contents [1], with some slight variations
described in the Trust Tokens design doc (currently internal-only;
working to release a public version).

This is a common ancestor CL of trust token issuance, redemption,
and key commitment fetching and parsing.

[1]:
https://github.com/alxdavids/draft-privacy-pass/blob/master/draft-privacy-pass.md#key-registration-registry

Bug: 1042962
Change-Id: Ic0a20cb266c8133bb3545821b975e813bfb59c50
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2062674
Commit-Queue: David Van Cleve <davidvc@chromium.org>
Reviewed-by: default avatarCharlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742669}
parent b9258679
......@@ -19,6 +19,8 @@ source_set("trust_tokens") {
"trust_token_database_owner.cc",
"trust_token_database_owner.h",
"trust_token_http_headers.h",
"trust_token_key_commitment_result.cc",
"trust_token_key_commitment_result.h",
"trust_token_operation_status.h",
"trust_token_parameterization.h",
"trust_token_persister.h",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/network/trust_tokens/trust_token_key_commitment_result.h"
#include <tuple>
namespace network {
TrustTokenKeyCommitmentResult::TrustTokenKeyCommitmentResult() = default;
TrustTokenKeyCommitmentResult::~TrustTokenKeyCommitmentResult() = default;
TrustTokenKeyCommitmentResult::TrustTokenKeyCommitmentResult(
const TrustTokenKeyCommitmentResult&) = default;
TrustTokenKeyCommitmentResult::TrustTokenKeyCommitmentResult(
TrustTokenKeyCommitmentResult&&) = default;
TrustTokenKeyCommitmentResult& TrustTokenKeyCommitmentResult::operator=(
const TrustTokenKeyCommitmentResult&) = default;
TrustTokenKeyCommitmentResult& TrustTokenKeyCommitmentResult::operator=(
TrustTokenKeyCommitmentResult&&) = default;
bool operator==(const TrustTokenKeyCommitmentResult::Key& lhs,
const TrustTokenKeyCommitmentResult::Key& rhs) {
return std::tie(lhs.body, lhs.expiry, lhs.label) ==
std::tie(rhs.body, rhs.expiry, rhs.label);
}
bool operator==(const TrustTokenKeyCommitmentResult& lhs,
const TrustTokenKeyCommitmentResult& rhs) {
return std::tie(lhs.batch_size, lhs.keys,
lhs.signed_redemption_record_verification_key) ==
std::tie(rhs.batch_size, rhs.keys,
rhs.signed_redemption_record_verification_key);
}
} // namespace network
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_NETWORK_TRUST_TOKENS_TRUST_TOKEN_KEY_COMMITMENT_RESULT_H_
#define SERVICES_NETWORK_TRUST_TOKENS_TRUST_TOKEN_KEY_COMMITMENT_RESULT_H_
#include <string>
#include <vector>
#include "base/optional.h"
#include "base/time/time.h"
namespace network {
// Struct TrustTokenKeyCommitmentResult represents a Trust Token issuer's
// current key commitments and associated information provided through the key
// commitment mechanism.
struct TrustTokenKeyCommitmentResult final {
TrustTokenKeyCommitmentResult();
~TrustTokenKeyCommitmentResult();
TrustTokenKeyCommitmentResult(const TrustTokenKeyCommitmentResult&);
TrustTokenKeyCommitmentResult(TrustTokenKeyCommitmentResult&&);
TrustTokenKeyCommitmentResult& operator=(
const TrustTokenKeyCommitmentResult&);
TrustTokenKeyCommitmentResult& operator=(TrustTokenKeyCommitmentResult&&);
struct Key {
std::string body;
base::Time expiry;
uint32_t label;
};
// |keys| is the collection of the issuer's current key commitments.
std::vector<Key> keys;
// |batch_size| is the issuer's optional number of tokens it wishes the client
// to request per Trust Tokens issuance operation.
base::Optional<int> batch_size;
// |signed_redemption_record_verification_key| is an Ed25519 public key that
// can be used to verify Signed Redemption Record (SRR) signatures
// subsequently provided by the issuer.
std::string signed_redemption_record_verification_key;
};
// For testing.
bool operator==(const TrustTokenKeyCommitmentResult::Key& lhs,
const TrustTokenKeyCommitmentResult::Key& rhs);
bool operator==(const TrustTokenKeyCommitmentResult& lhs,
const TrustTokenKeyCommitmentResult& rhs);
} // namespace network
#endif // SERVICES_NETWORK_TRUST_TOKENS_TRUST_TOKEN_KEY_COMMITMENT_RESULT_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment