1 // Copyright 2023 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 //////////////////////////////////////////////////////////////////////////////// 16 17 package com.google.crypto.tink.hybrid; 18 19 import com.google.crypto.tink.Key; 20 import com.google.crypto.tink.PrivateKey; 21 import com.google.crypto.tink.util.Bytes; 22 import com.google.errorprone.annotations.Immutable; 23 import javax.annotation.Nullable; 24 25 /** 26 * Representation of the decryption function for a hybrid encryption primitive. 27 * 28 * <p>The encryption function is available via {@link #getPublicKey}. 29 */ 30 @Immutable 31 public abstract class HybridPrivateKey extends Key implements PrivateKey { 32 @Override getPublicKey()33 public abstract HybridPublicKey getPublicKey(); 34 35 /** 36 * Returns a {@link Bytes} instance, which is prefixed to every ciphertext. 37 * 38 * <p>Returns the same as {@code getPublicKey().getOutputPrefix()}. 39 */ getOutputPrefix()40 public final Bytes getOutputPrefix() { 41 return getPublicKey().getOutputPrefix(); 42 } 43 44 @Override 45 @Nullable getIdRequirementOrNull()46 public Integer getIdRequirementOrNull() { 47 return getPublicKey().getIdRequirementOrNull(); 48 } 49 50 @Override getParameters()51 public HybridParameters getParameters() { 52 return getPublicKey().getParameters(); 53 } 54 } 55