1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.adservices.service.kanon;
18 
19 import com.google.protobuf.InvalidProtocolBufferException;
20 
21 import private_join_and_compute.anonymous_counting_tokens.ClientParameters;
22 import private_join_and_compute.anonymous_counting_tokens.ClientPrivateParameters;
23 import private_join_and_compute.anonymous_counting_tokens.ClientPublicParameters;
24 import private_join_and_compute.anonymous_counting_tokens.GeneratedTokensRequestProto;
25 import private_join_and_compute.anonymous_counting_tokens.MessagesSet;
26 import private_join_and_compute.anonymous_counting_tokens.SchemeParameters;
27 import private_join_and_compute.anonymous_counting_tokens.ServerPublicParameters;
28 import private_join_and_compute.anonymous_counting_tokens.TokensRequest;
29 import private_join_and_compute.anonymous_counting_tokens.TokensRequestPrivateState;
30 import private_join_and_compute.anonymous_counting_tokens.TokensResponse;
31 import private_join_and_compute.anonymous_counting_tokens.TokensSet;
32 
33 public interface AnonymousCountingTokens {
34 
35     /**
36      * Returns a fresh set of Client parameters corresponding to these SchemeParameters and
37      * ServerPublicParameters.
38      */
generateClientParameters( SchemeParameters schemeParametersProto, ServerPublicParameters serverPublicParametersProto)39     ClientParameters generateClientParameters(
40             SchemeParameters schemeParametersProto,
41             ServerPublicParameters serverPublicParametersProto)
42             throws InvalidProtocolBufferException;
43 
44     /**
45      * Returns a tuple of client_fingerprints, TokensRequest and TokensRequestPrivateState for the
46      * given set of messages.
47      */
generateTokensRequest( MessagesSet messagesProto, SchemeParameters schemeParametersProto, ClientPublicParameters clientPublicParametersProto, ClientPrivateParameters clientPrivateParametersProto, ServerPublicParameters serverPublicParameters)48     GeneratedTokensRequestProto generateTokensRequest(
49             MessagesSet messagesProto,
50             SchemeParameters schemeParametersProto,
51             ClientPublicParameters clientPublicParametersProto,
52             ClientPrivateParameters clientPrivateParametersProto,
53             ServerPublicParameters serverPublicParameters)
54             throws InvalidProtocolBufferException;
55 
56     /**
57      * Returns {@code true} on a valid response. Returns {@code false} if the parameters don't
58      * correspond to ACT v0.
59      */
verifyTokensResponse( MessagesSet messagesProto, TokensRequest tokensRequestProto, TokensRequestPrivateState tokensRequestPrivateStateProto, TokensResponse tokenResponseProto, SchemeParameters schemeParametersProto, ClientPublicParameters clientPublicParametersProto, ClientPrivateParameters clientPrivateParametersProto, ServerPublicParameters serverPublicParameters)60     boolean verifyTokensResponse(
61             MessagesSet messagesProto,
62             TokensRequest tokensRequestProto,
63             TokensRequestPrivateState tokensRequestPrivateStateProto,
64             TokensResponse tokenResponseProto,
65             SchemeParameters schemeParametersProto,
66             ClientPublicParameters clientPublicParametersProto,
67             ClientPrivateParameters clientPrivateParametersProto,
68             ServerPublicParameters serverPublicParameters);
69 
70     /** Returns a vector of tokens corresponding to the supplied messages. */
recoverTokens( MessagesSet messagesProto, TokensRequest tokensRequestProto, TokensRequestPrivateState tokensRequestPrivateStateProto, TokensResponse tokenResponseProto, SchemeParameters schemeParametersProto, ClientPublicParameters clientPublicParametersProto, ClientPrivateParameters clientPrivateParametersProto, ServerPublicParameters serverPublicParameters)71     TokensSet recoverTokens(
72             MessagesSet messagesProto,
73             TokensRequest tokensRequestProto,
74             TokensRequestPrivateState tokensRequestPrivateStateProto,
75             TokensResponse tokenResponseProto,
76             SchemeParameters schemeParametersProto,
77             ClientPublicParameters clientPublicParametersProto,
78             ClientPrivateParameters clientPrivateParametersProto,
79             ServerPublicParameters serverPublicParameters)
80             throws InvalidProtocolBufferException;
81 }
82