Skip to content

Commit 116b96e

Browse files
fundthmcalculusallibell
authored andcommitted
Expose blake3 hashing to SDKs (#356)
1 parent 158b331 commit 116b96e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5655
-584
lines changed

docs/reference/proto/index.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88

99
- [SecureExampleService](#okapi.examples.v1.SecureExampleService)
1010

11+
- [okapi/hashing/v1/hashing.proto](#okapi/hashing/v1/hashing.proto)
12+
- [Blake3DeriveKeyRequest](#okapi.hashing.v1.Blake3DeriveKeyRequest)
13+
- [Blake3DeriveKeyResponse](#okapi.hashing.v1.Blake3DeriveKeyResponse)
14+
- [Blake3HashRequest](#okapi.hashing.v1.Blake3HashRequest)
15+
- [Blake3HashResponse](#okapi.hashing.v1.Blake3HashResponse)
16+
- [Blake3KeyedHashRequest](#okapi.hashing.v1.Blake3KeyedHashRequest)
17+
- [Blake3KeyedHashResponse](#okapi.hashing.v1.Blake3KeyedHashResponse)
18+
1119
- [okapi/keys/v1/keys.proto](#okapi/keys/v1/keys.proto)
1220
- [GenerateKeyRequest](#okapi.keys.v1.GenerateKeyRequest)
1321
- [GenerateKeyResponse](#okapi.keys.v1.GenerateKeyResponse)
@@ -107,6 +115,114 @@
107115

108116

109117

118+
<a name="okapi/hashing/v1/hashing.proto"></a>
119+
<p align="right"><a href="#top">Top</a></p>
120+
121+
## okapi/hashing/v1/hashing.proto
122+
123+
124+
125+
<a name="okapi.hashing.v1.Blake3DeriveKeyRequest"></a>
126+
127+
### Blake3DeriveKeyRequest
128+
129+
130+
131+
| Field | Type | Label | Description |
132+
| ----- | ---- | ----- | ----------- |
133+
| context | [bytes](#bytes) | | |
134+
| key_material | [bytes](#bytes) | | |
135+
136+
137+
138+
139+
140+
141+
<a name="okapi.hashing.v1.Blake3DeriveKeyResponse"></a>
142+
143+
### Blake3DeriveKeyResponse
144+
145+
146+
147+
| Field | Type | Label | Description |
148+
| ----- | ---- | ----- | ----------- |
149+
| digest | [bytes](#bytes) | | |
150+
151+
152+
153+
154+
155+
156+
<a name="okapi.hashing.v1.Blake3HashRequest"></a>
157+
158+
### Blake3HashRequest
159+
160+
161+
162+
| Field | Type | Label | Description |
163+
| ----- | ---- | ----- | ----------- |
164+
| data | [bytes](#bytes) | | |
165+
166+
167+
168+
169+
170+
171+
<a name="okapi.hashing.v1.Blake3HashResponse"></a>
172+
173+
### Blake3HashResponse
174+
175+
176+
177+
| Field | Type | Label | Description |
178+
| ----- | ---- | ----- | ----------- |
179+
| digest | [bytes](#bytes) | | |
180+
181+
182+
183+
184+
185+
186+
<a name="okapi.hashing.v1.Blake3KeyedHashRequest"></a>
187+
188+
### Blake3KeyedHashRequest
189+
190+
191+
192+
| Field | Type | Label | Description |
193+
| ----- | ---- | ----- | ----------- |
194+
| data | [bytes](#bytes) | | |
195+
| key | [bytes](#bytes) | | |
196+
197+
198+
199+
200+
201+
202+
<a name="okapi.hashing.v1.Blake3KeyedHashResponse"></a>
203+
204+
### Blake3KeyedHashResponse
205+
206+
207+
208+
| Field | Type | Label | Description |
209+
| ----- | ---- | ----- | ----------- |
210+
| digest | [bytes](#bytes) | | |
211+
212+
213+
214+
215+
216+
217+
218+
219+
220+
221+
222+
223+
224+
225+
110226
<a name="okapi/keys/v1/keys.proto"></a>
111227
<p align="right"><a href="#top">Top</a></p>
112228

dotnet/Directory.Build.props

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
<Project>
2-
<!-- Set common properties regarding assembly information and nuget packages -->
3-
<PropertyGroup>
4-
<Authors>Trinsic Engineering Team</Authors>
5-
<Company>Trinsic</Company>
6-
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
7-
<PackageProjectUrl>https://github.com/trinsic-id/okapi</PackageProjectUrl>
8-
<PackageTags>BBS+ Ursa ZKP</PackageTags>
9-
<Product>Okapi</Product>
10-
<RepositoryUrl>https://github.com/trinsic-id/okapi.git</RepositoryUrl>
11-
<RepositoryType>git</RepositoryType>
12-
<Version>1.0.0</Version>
13-
<IncludeSymbols>true</IncludeSymbols>
14-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
15-
</PropertyGroup>
16-
<!-- Common compile parameters -->
17-
<PropertyGroup>
18-
<!-- We use full (Windows PDBs) until cross platform support for source link will get better -->
19-
<DebugType>full</DebugType>
20-
<LangVersion>latest</LangVersion>
21-
<NoWarn>$(NoWarn);1591</NoWarn>
22-
<Nullable>disable</Nullable>
23-
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
24-
</PropertyGroup>
2+
<!-- Set common properties regarding assembly information and nuget packages -->
3+
<PropertyGroup>
4+
<Authors>Trinsic Engineering Team</Authors>
5+
<Company>Trinsic</Company>
6+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
7+
<PackageProjectUrl>https://github.com/trinsic-id/okapi</PackageProjectUrl>
8+
<PackageTags>BBS+ Ursa ZKP</PackageTags>
9+
<Product>Okapi</Product>
10+
<RepositoryUrl>https://github.com/trinsic-id/okapi.git</RepositoryUrl>
11+
<RepositoryType>git</RepositoryType>
12+
<Version>1.0.0</Version>
13+
<IncludeSymbols>true</IncludeSymbols>
14+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
15+
</PropertyGroup>
16+
<!-- Common compile parameters -->
17+
<PropertyGroup>
18+
<!-- We use full (Windows PDBs) until cross platform support for source link will get better -->
19+
<DebugType>full</DebugType>
20+
<LangVersion>latest</LangVersion>
21+
<NoWarn>$(NoWarn);1591</NoWarn>
22+
<Nullable>disable</Nullable>
23+
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
24+
</PropertyGroup>
2525
</Project>

dotnet/Library/Okapi/ByteBuffer.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
using System;
22
using System.Runtime.InteropServices;
33

4-
namespace Okapi
4+
namespace Okapi;
5+
6+
[StructLayout(LayoutKind.Sequential)]
7+
internal struct ByteBuffer
58
{
6-
[StructLayout(LayoutKind.Sequential)]
7-
internal struct ByteBuffer
8-
{
9-
public long Length;
10-
public IntPtr Data;
11-
}
9+
public long Length;
10+
public IntPtr Data;
1211
}

dotnet/Library/Okapi/DIDComm.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
using Google.Protobuf;
21
using Okapi.Transport.V1;
32

4-
namespace Okapi.Transport
3+
namespace Okapi.Transport;
4+
5+
public static class DIDComm
56
{
6-
public static class DIDComm
7+
public static PackResponse Pack(PackRequest request)
78
{
8-
public static PackResponse Pack(PackRequest request) =>
9-
Native.Call<PackRequest, PackResponse>(request, Native.didcomm_pack);
9+
return Native.Call<PackRequest, PackResponse>(request, Native.didcomm_pack);
10+
}
1011

11-
public static UnpackResponse Unpack(UnpackRequest request) =>
12-
Native.Call<UnpackRequest, UnpackResponse>(request, Native.didcomm_unpack);
12+
public static UnpackResponse Unpack(UnpackRequest request)
13+
{
14+
return Native.Call<UnpackRequest, UnpackResponse>(request, Native.didcomm_unpack);
15+
}
1316

14-
public static SignResponse Sign(SignRequest request) =>
15-
Native.Call<SignRequest, SignResponse>(request, Native.didcomm_sign);
17+
public static SignResponse Sign(SignRequest request)
18+
{
19+
return Native.Call<SignRequest, SignResponse>(request, Native.didcomm_sign);
20+
}
1621

17-
public static VerifyResponse Verify(VerifyRequest request) =>
18-
Native.Call<VerifyRequest, VerifyResponse>(request, Native.didcomm_verify);
22+
public static VerifyResponse Verify(VerifyRequest request)
23+
{
24+
return Native.Call<VerifyRequest, VerifyResponse>(request, Native.didcomm_verify);
1925
}
20-
}
26+
}
Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
using System;
2+
using System.Runtime.Serialization;
23

3-
namespace Okapi
4+
namespace Okapi;
5+
6+
[Serializable]
7+
public class DIDCommException : Exception
48
{
5-
[Serializable]
6-
public class DIDCommException : Exception
9+
public DIDCommException()
10+
{
11+
}
12+
13+
public DIDCommException(int code, string message) : this(message)
14+
{
15+
Code = code;
16+
}
17+
18+
public DIDCommException(string message) : base(message)
719
{
8-
public int Code { get; }
9-
public DIDCommException() { }
10-
public DIDCommException(int code, string message) : this(message)
11-
{
12-
Code = code;
13-
}
14-
public DIDCommException(string message) : base(message) { }
15-
public DIDCommException(string message, Exception inner) : base(message, inner) { }
16-
protected DIDCommException(
17-
System.Runtime.Serialization.SerializationInfo info,
18-
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
1920
}
20-
}
21+
22+
public DIDCommException(string message, Exception inner) : base(message, inner)
23+
{
24+
}
25+
26+
protected DIDCommException(
27+
SerializationInfo info,
28+
StreamingContext context) : base(info, context)
29+
{
30+
}
31+
32+
public int Code { get; }
33+
}

dotnet/Library/Okapi/DIDKey.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
using Okapi.Keys.V1;
22

3-
namespace Okapi.Keys
3+
namespace Okapi.Keys;
4+
5+
public static class DIDKey
46
{
5-
public static class DIDKey
7+
/// <summary>
8+
/// Generate new key
9+
/// </summary>
10+
/// <param name="request"></param>
11+
/// <returns></returns>
12+
public static GenerateKeyResponse Generate(GenerateKeyRequest request)
613
{
7-
/// <summary>
8-
/// Generate new key
9-
/// </summary>
10-
/// <param name="request"></param>
11-
/// <returns></returns>
12-
public static GenerateKeyResponse Generate(GenerateKeyRequest request) =>
13-
Native.Call<GenerateKeyRequest, GenerateKeyResponse>(request, Native.didkey_generate);
14+
return Native.Call<GenerateKeyRequest, GenerateKeyResponse>(request, Native.didkey_generate);
15+
}
1416

15-
public static ResolveResponse Resolve(ResolveRequest request) =>
16-
Native.Call<ResolveRequest, ResolveResponse>(request, Native.didkey_resolve);
17+
public static ResolveResponse Resolve(ResolveRequest request)
18+
{
19+
return Native.Call<ResolveRequest, ResolveResponse>(request, Native.didkey_resolve);
1720
}
18-
}
21+
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
using System;
22
using System.Runtime.InteropServices;
33

4-
namespace Okapi
4+
namespace Okapi;
5+
6+
[StructLayout(LayoutKind.Sequential)]
7+
internal struct ExternError
58
{
6-
[StructLayout(LayoutKind.Sequential)]
7-
internal struct ExternError
8-
{
9-
internal int Code;
10-
internal IntPtr Message;
11-
}
12-
}
9+
internal int Code;
10+
internal IntPtr Message;
11+
}

dotnet/Library/Okapi/Hashing.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Okapi.Hashing.V1;
2+
3+
namespace Okapi.Hashing;
4+
5+
public static class Blake3
6+
{
7+
/// <summary>
8+
/// Generate new key
9+
/// </summary>
10+
/// <param name="request"></param>
11+
/// <returns></returns>
12+
public static Blake3HashResponse Hash(Blake3HashRequest request)
13+
{
14+
return Native.Call<Blake3HashRequest, Blake3HashResponse>(request, Native.blake3_hash);
15+
}
16+
17+
public static Blake3KeyedHashResponse KeyedHash(Blake3KeyedHashRequest request)
18+
{
19+
return Native.Call<Blake3KeyedHashRequest, Blake3KeyedHashResponse>(request, Native.blake3_keyed_hash);
20+
}
21+
22+
public static Blake3DeriveKeyResponse DeriveKey(Blake3DeriveKeyRequest request)
23+
{
24+
return Native.Call<Blake3DeriveKeyRequest, Blake3DeriveKeyResponse>(request, Native.blake3_derive_key);
25+
}
26+
}

0 commit comments

Comments
 (0)