tangled
alpha
login
or
join now
stream.place
/
streamplace
74
fork
atom
Live video on the AT Protocol
74
fork
atom
overview
issues
1
pulls
pipelines
rust: was it just certs the whole time?
Eli Mallon
3 months ago
fb0de4e7
54029dd0
+22
-12
6 changed files
expand all
collapse all
unified
split
Cargo.lock
pkg
iroh
generated
iroh_streamplace
iroh_streamplace.go
iroh_streamplace.h
media
media_signer.go
rust
iroh-streamplace
Cargo.toml
src
c2pa.rs
+1
Cargo.lock
···
2734
2734
dependencies = [
2735
2735
"anyhow",
2736
2736
"async-trait",
2737
2737
+
"base64 0.22.1",
2737
2738
"bytes",
2738
2739
"c2pa 0.58.0 (git+https://github.com/streamplace/c2pa-rs.git?rev=544825abfaf9e588813e18dba70c8d5afd039d46)",
2739
2740
"hex",
+6
-6
pkg/iroh/generated/iroh_streamplace/iroh_streamplace.go
···
414
414
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
415
415
return C.uniffi_iroh_streamplace_checksum_func_sign()
416
416
})
417
417
-
if checksum != 50601 {
417
417
+
if checksum != 41179 {
418
418
// If this happens try cleaning and rebuilding your project
419
419
panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_func_sign: UniFFI API checksum mismatch")
420
420
}
···
423
423
checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t {
424
424
return C.uniffi_iroh_streamplace_checksum_func_sign_with_ingredients()
425
425
})
426
426
-
if checksum != 52190 {
426
426
+
if checksum != 15411 {
427
427
// If this happens try cleaning and rebuilding your project
428
428
panic("iroh_streamplace: uniffi_iroh_streamplace_checksum_func_sign_with_ingredients: UniFFI API checksum mismatch")
429
429
}
···
5654
5654
return _uniffiErr.AsError()
5655
5655
}
5656
5656
5657
5657
-
func Sign(manifest string, data Stream, certs []byte, gosigner GoSigner) ([]byte, error) {
5657
5657
+
func Sign(manifest string, data Stream, certsStr string, gosigner GoSigner) ([]byte, error) {
5658
5658
_uniffiRV, _uniffiErr := rustCallWithError[SpError](FfiConverterSpError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI {
5659
5659
return GoRustBuffer{
5660
5660
-
inner: C.uniffi_iroh_streamplace_fn_func_sign(FfiConverterStringINSTANCE.Lower(manifest), FfiConverterStreamINSTANCE.Lower(data), FfiConverterBytesINSTANCE.Lower(certs), FfiConverterGoSignerINSTANCE.Lower(gosigner), _uniffiStatus),
5660
5660
+
inner: C.uniffi_iroh_streamplace_fn_func_sign(FfiConverterStringINSTANCE.Lower(manifest), FfiConverterStreamINSTANCE.Lower(data), FfiConverterStringINSTANCE.Lower(certsStr), FfiConverterGoSignerINSTANCE.Lower(gosigner), _uniffiStatus),
5661
5661
}
5662
5662
})
5663
5663
if _uniffiErr != nil {
···
5668
5668
}
5669
5669
}
5670
5670
5671
5671
-
func SignWithIngredients(manifest string, data Stream, certs []byte, ingredients ManyStreams, gosigner GoSigner, output Stream) error {
5671
5671
+
func SignWithIngredients(manifest string, data Stream, certsStr string, ingredients ManyStreams, gosigner GoSigner, output Stream) error {
5672
5672
_, _uniffiErr := rustCallWithError[SpError](FfiConverterSpError{}, func(_uniffiStatus *C.RustCallStatus) bool {
5673
5673
-
C.uniffi_iroh_streamplace_fn_func_sign_with_ingredients(FfiConverterStringINSTANCE.Lower(manifest), FfiConverterStreamINSTANCE.Lower(data), FfiConverterBytesINSTANCE.Lower(certs), FfiConverterManyStreamsINSTANCE.Lower(ingredients), FfiConverterGoSignerINSTANCE.Lower(gosigner), FfiConverterStreamINSTANCE.Lower(output), _uniffiStatus)
5673
5673
+
C.uniffi_iroh_streamplace_fn_func_sign_with_ingredients(FfiConverterStringINSTANCE.Lower(manifest), FfiConverterStreamINSTANCE.Lower(data), FfiConverterStringINSTANCE.Lower(certsStr), FfiConverterManyStreamsINSTANCE.Lower(ingredients), FfiConverterGoSignerINSTANCE.Lower(gosigner), FfiConverterStreamINSTANCE.Lower(output), _uniffiStatus)
5674
5674
return false
5675
5675
})
5676
5676
return _uniffiErr.AsError()
+2
-2
pkg/iroh/generated/iroh_streamplace/iroh_streamplace.h
···
1054
1054
#endif
1055
1055
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_SIGN
1056
1056
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_SIGN
1057
1057
-
RustBuffer uniffi_iroh_streamplace_fn_func_sign(RustBuffer manifest, void* data, RustBuffer certs, void* gosigner, RustCallStatus *out_status
1057
1057
+
RustBuffer uniffi_iroh_streamplace_fn_func_sign(RustBuffer manifest, void* data, RustBuffer certs_str, void* gosigner, RustCallStatus *out_status
1058
1058
);
1059
1059
#endif
1060
1060
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_SIGN_WITH_INGREDIENTS
1061
1061
#define UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_SIGN_WITH_INGREDIENTS
1062
1062
-
void uniffi_iroh_streamplace_fn_func_sign_with_ingredients(RustBuffer manifest, void* data, RustBuffer certs, void* ingredients, void* gosigner, void* output, RustCallStatus *out_status
1062
1062
+
void uniffi_iroh_streamplace_fn_func_sign_with_ingredients(RustBuffer manifest, void* data, RustBuffer certs_str, void* ingredients, void* gosigner, void* output, RustCallStatus *out_status
1063
1063
);
1064
1064
#endif
1065
1065
#ifndef UNIFFI_FFIDEF_UNIFFI_IROH_STREAMPLACE_FN_FUNC_SUBSCRIBE_ITEM_DEBUG
+3
-2
pkg/media/media_signer.go
···
6
6
"crypto/ecdsa"
7
7
"crypto/rand"
8
8
"crypto/sha256"
9
9
+
"encoding/base64"
9
10
"encoding/json"
10
11
"fmt"
11
12
"io"
···
160
161
rustCallbackSigner := &RustCallbackSigner{
161
162
Signer: ms.Signer,
162
163
}
163
163
-
bs, err = iroh_streamplace.Sign(string(manifestBs), c2patypes.NewReader(aqio.NewReadWriteSeeker(bs)), ms.Cert, rustCallbackSigner)
164
164
+
bs, err = iroh_streamplace.Sign(string(manifestBs), c2patypes.NewReader(aqio.NewReadWriteSeeker(bs)), base64.StdEncoding.EncodeToString(ms.Cert), rustCallbackSigner)
164
165
if err != nil {
165
166
return nil, err
166
167
}
···
232
233
for _, ingredient := range ingredients {
233
234
many.AddStream(ingredient)
234
235
}
235
235
-
err = iroh_streamplace.SignWithIngredients(string(manifestBs), c2patypes.NewReader(input), ms.Cert, many, rustCallbackSigner, c2patypes.NewWriter(output))
236
236
+
err = iroh_streamplace.SignWithIngredients(string(manifestBs), c2patypes.NewReader(input), base64.StdEncoding.EncodeToString(ms.Cert), many, rustCallbackSigner, c2patypes.NewWriter(output))
236
237
if err != nil {
237
238
return err
238
239
}
+1
rust/iroh-streamplace/Cargo.toml
···
36
36
iroh-gossip = "0.93.1"
37
37
ref-cast = "1.0.25"
38
38
rand = "0.9"
39
39
+
base64 = "0.22.1"
39
40
40
41
[dev-dependencies]
41
42
testresult = "0.4.1"
+9
-2
rust/iroh-streamplace/src/c2pa.rs
···
16
16
use serde_json;
17
17
18
18
use crate::error::SPError;
19
19
+
use base64::{Engine as _, engine::general_purpose::STANDARD};
19
20
#[uniffi::export]
20
21
pub fn get_manifest_and_cert(data: &dyn Stream) -> Result<String, SPError> {
21
22
let reader = Reader::from_stream("video/mp4", StreamAdapter::from(data))
···
111
112
pub fn sign(
112
113
manifest: String,
113
114
data: &dyn Stream,
114
114
-
certs: Vec<u8>,
115
115
+
certs_str: String,
115
116
gosigner: Arc<dyn GoSigner>,
116
117
) -> Result<Vec<u8>, SPError> {
117
118
Settings::from_toml(TOML_SETTINGS).map_err(|e| SPError::C2paError(e.to_string()))?;
119
119
+
let certs = STANDARD
120
120
+
.decode(certs_str)
121
121
+
.map_err(|e| SPError::C2paError(e.to_string()))?;
118
122
let callback_signer = CallbackSigner::new(
119
123
move |_context: *const (), data: &[u8]| {
120
124
let signature = gosigner
···
242
246
pub fn sign_with_ingredients(
243
247
manifest: String,
244
248
data: &dyn Stream,
245
245
-
certs: Vec<u8>,
249
249
+
certs_str: String,
246
250
ingredients: &dyn ManyStreams,
247
251
gosigner: Arc<dyn GoSigner>,
248
252
output: &dyn Stream,
249
253
) -> Result<(), SPError> {
254
254
+
let certs = STANDARD
255
255
+
.decode(certs_str)
256
256
+
.map_err(|e| SPError::C2paError(e.to_string()))?;
250
257
Settings::from_toml(TOML_SETTINGS).map_err(|e| SPError::C2paError(e.to_string()))?;
251
258
let callback_signer = CallbackSigner::new(
252
259
move |_context: *const (), data: &[u8]| {