@@ -156,28 +156,19 @@ module {:options "/functionSyntax:4" } HierarchicalVersionUtils {
156
156
input: Types .EncryptionContextString
157
157
): (output: Result< Types. EncryptionContext, string > )
158
158
ensures output. Success? ==> |output. value| == |input| // Output map size equals input map size
159
- ensures output. Failure? ==> output. error == "Unable to encode string "
160
159
{
161
- var encodedEncryptionContext
162
- := set k < - input
163
- ::
164
- (UTF8. Encode (k), UTF8. Encode (input[k]), k);
160
+ var encodedInputResult: seq < (string , (UTF8. ValidUTF8Bytes, UTF8. ValidUTF8Bytes))> :- Seq. MapWithResult (
161
+ // Dafny requires the type of the element being mapped over, or it feaks out.
162
+ (strKey: string )
163
+ =>
164
+ var keyValueUtf8 :- Utf8EncodeKeyValue (strKey, input[strKey]);
165
+ Success (strKey, keyValueUtf8),
166
+ input. Keys
167
+ );
165
168
166
- if (forall i < - encodedEncryptionContext
167
- ::
168
- && i. 0. Success?
169
- && i. 1. Success?)
170
- then
171
- var resultMap := map i < - encodedEncryptionContext :: i. 0. value := i. 1. value;
172
- if |resultMap| == |input| then
173
- Success (resultMap)
174
- else
175
- Failure ("Unable to encode string")
176
- else
177
- Failure ("Unable to encode string")
178
169
}
179
170
180
- function method Utf8EncodeKeyValue (
171
+ function Utf8EncodeKeyValue (
181
172
strKey: string ,
182
173
strValue: string
183
174
) : (res: Result< (UTF8. ValidUTF8Bytes, UTF8. ValidUTF8Bytes), Types. Error> )
@@ -199,12 +190,6 @@ module {:options "/functionSyntax:4" } HierarchicalVersionUtils {
199
190
Success ((key, value))
200
191
}
201
192
202
- function method WrapStringToError (e: string )
203
- :(ret: Types. Error)
204
- {
205
- Types. KeyStoreException ( message := e )
206
- }
207
-
208
193
// Helper function to decode encryption context from UTF8 bytes map to string map
209
194
function DecodeEncryptionContext (
210
195
input: Types .EncryptionContext
0 commit comments