Resource
PublicKey
Singleton resource representing an encryption public key. Resource Patterns:dataProviders/{data_provider}/publicKeymeasurementConsumers/{measurement_consumer}/publicKey
Each parent resource has exactly one PublicKey singleton resource.
Resource name.Format:
dataProviders/{data_provider}/publicKeymeasurementConsumers/{measurement_consumer}/publicKey
Serialized
EncryptionPublicKey for the parent resource, which can be verified using certificate.The version of the EncryptionPublicKey message must match the API version used to last update this resource.Resource name of the Certificate that can be used to verify
public_key.This must have the same parent as the PublicKey.Format: {parent}/certificates/{certificate}EncryptionPublicKey
Thepublic_key field contains a signed EncryptionPublicKey message:
Format of data for this public key.Values:
FORMAT_UNSPECIFIED- Default valueTINK_KEYSET- Tink Keyset format
The format-specific key data.For
TINK_KEYSET format: Serialized google.crypto.tink.Keyset message. Encrypted message values use Tink’s wire format.format and data together must specify all necessary information to decrypt messages given a private key.Methods
UpdatePublicKey
Updates the PublicKey for the specified parent.This method performs a full replacement update. Partial updates are not supported.
Resource to update.Must include the resource name to identify which PublicKey to update.
The updated PublicKey resource.
Example Request
SignedMessage Structure
EncryptionPublicKey Structure
Error Conditions
NOT_FOUND- Parent resource or certificate not foundINVALID_ARGUMENT- Invalid public key data, signature, or mismatched parentPERMISSION_DENIED- Caller lacks permission to update the public keyFAILED_PRECONDITION- Certificate cannot verify the signature
Usage Patterns
Creating a Signed Public Key
- Generate encryption key pair:
- Serialize the public key:
- Sign the serialized key:
EncryptionPublicKey using the private key associated with your certificate.
- Create the SignedMessage:
- Update the PublicKey resource:
Rotating Public Keys
To rotate encryption keys:- Generate new key pair
- Create new certificate (if needed) via Certificates API
- Update PublicKey with new key and certificate reference
- Update local systems to use new private key for decryption
- Maintain old private key temporarily to decrypt in-flight messages
Verifying a Public Key
When receiving encrypted data:- Fetch the PublicKey resource:
- Fetch the referenced Certificate:
- Verify the signature:
signature in the SignedMessage.
- Extract and use the public key:
EncryptionPublicKey from the message field and use it to encrypt data for the parent resource.
Tink Keyset Format
When usingTINK_KEYSET format:
- The
datafield contains a serializedgoogle.crypto.tink.Keysetmessage - Encrypted messages use Tink’s wire format
- See Tink documentation for keyset structure
Example Tink Keyset Usage
Signature Algorithms
Common signature algorithm OIDs:| Algorithm | OID |
|---|---|
| SHA256withRSA | 1.2.840.113549.1.1.11 |
| SHA384withRSA | 1.2.840.113549.1.1.12 |
| SHA512withRSA | 1.2.840.113549.1.1.13 |
| SHA256withECDSA | 1.2.840.10045.4.3.2 |
| SHA384withECDSA | 1.2.840.10045.4.3.3 |
| SHA512withECDSA | 1.2.840.10045.4.3.4 |
Security Considerations
The PublicKey resource is a singleton - each parent has exactly one. Updating it replaces the previous key entirely.
Best Practices
- Certificate Management: Ensure the referenced certificate is valid before updating the public key
- Version Matching: The
EncryptionPublicKeymessage version must match the API version - Signature Verification: Always verify the signature using the referenced certificate
- Key Rotation: Plan for key rotation by maintaining old private keys during transition
- Format Consistency: Use
TINK_KEYSETformat for compatibility with Tink cryptographic library
