pub struct JsSignedJson { /* private fields */ }
Expand description
JSON signed by a multicipher key. Since the signature is done on a digest created by {@link digestJson}, the same signature can be validated against different selectively revealed JSON documents.
@see selectiveDigestJson
Implementations§
Source§impl JsSignedJson
impl JsSignedJson
Sourcepub fn new(
public_key: &JsMPublicKey,
content: &JsValue,
signature: &JsMSignature,
) -> Result<JsSignedJson, JsValue>
pub fn new( public_key: &JsMPublicKey, content: &JsValue, signature: &JsMSignature, ) -> Result<JsSignedJson, JsValue>
Create {@link SignedJson} from its parts.
Sourcepub fn public_key(&self) -> JsMPublicKey
pub fn public_key(&self) -> JsMPublicKey
Accessor of the {@link PublicKey} that signed the binary data.
Sourcepub fn signature(&self) -> JsMSignature
pub fn signature(&self) -> JsMSignature
Accessor of the {@link Signature}.
Sourcepub fn validate(&self) -> bool
pub fn validate(&self) -> bool
Verify if {@link signature} was made by the private key that belongs to {@link publicKey} on the {@link content}.
Sourcepub fn validate_with_keyid(&self, signer_id: &JsMKeyId) -> bool
pub fn validate_with_keyid(&self, signer_id: &JsMKeyId) -> bool
Not only validate the signature, but also check if the provided {@link KeyId} was made from {@link publicKey}.
@see validate
Sourcepub fn validate_with_did_doc(
&self,
did_doc_str: &str,
from_height_inc: Option<u32>,
until_height_exc: Option<u32>,
) -> Result<JsValue, JsValue>
pub fn validate_with_did_doc( &self, did_doc_str: &str, from_height_inc: Option<u32>, until_height_exc: Option<u32>, ) -> Result<JsValue, JsValue>
Not only validate the signature, but also check the signing key had impersonation right the whole time period specified by the optional upper and lower block height boundaries. The DID document serialized as a string provides the whole history of key rights, so depending on the use-case there are three possible outcomes:
- The signing key had impersonation right the whole time and the signature is valid (green)
- Cannot prove if the signing key had impersonation right the whole time, but no other issues found (yellow)
- The signature is invalid or we can prove the signing key did not have impersonation right at any point in the given time interval (red)
The return value is a {@link ValidationResult}
Trait Implementations§
Source§impl From<JsSignedJson> for JsValue
impl From<JsSignedJson> for JsValue
Source§fn from(value: JsSignedJson) -> JsValue
fn from(value: JsSignedJson) -> JsValue
Source§impl FromWasmAbi for JsSignedJson
impl FromWasmAbi for JsSignedJson
Source§impl IntoWasmAbi for JsSignedJson
impl IntoWasmAbi for JsSignedJson
Source§impl LongRefFromWasmAbi for JsSignedJson
impl LongRefFromWasmAbi for JsSignedJson
Source§type Anchor = RcRef<JsSignedJson>
type Anchor = RcRef<JsSignedJson>
RefFromWasmAbi::Anchor
Source§unsafe fn long_ref_from_abi(
js: <JsSignedJson as LongRefFromWasmAbi>::Abi,
) -> <JsSignedJson as LongRefFromWasmAbi>::Anchor
unsafe fn long_ref_from_abi( js: <JsSignedJson as LongRefFromWasmAbi>::Abi, ) -> <JsSignedJson as LongRefFromWasmAbi>::Anchor
RefFromWasmAbi::ref_from_abi
Source§impl OptionFromWasmAbi for JsSignedJson
impl OptionFromWasmAbi for JsSignedJson
Source§fn is_none(abi: &<JsSignedJson as FromWasmAbi>::Abi) -> bool
fn is_none(abi: &<JsSignedJson as FromWasmAbi>::Abi) -> bool
None
, and otherwise it will be passed to
FromWasmAbi
.Source§impl OptionIntoWasmAbi for JsSignedJson
impl OptionIntoWasmAbi for JsSignedJson
Source§fn none() -> <JsSignedJson as IntoWasmAbi>::Abi
fn none() -> <JsSignedJson as IntoWasmAbi>::Abi
None
branch of this option. Read moreSource§impl RefFromWasmAbi for JsSignedJson
impl RefFromWasmAbi for JsSignedJson
Source§type Anchor = RcRef<JsSignedJson>
type Anchor = RcRef<JsSignedJson>
Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§unsafe fn ref_from_abi(
js: <JsSignedJson as RefFromWasmAbi>::Abi,
) -> <JsSignedJson as RefFromWasmAbi>::Anchor
unsafe fn ref_from_abi( js: <JsSignedJson as RefFromWasmAbi>::Abi, ) -> <JsSignedJson as RefFromWasmAbi>::Anchor
Source§impl RefMutFromWasmAbi for JsSignedJson
impl RefMutFromWasmAbi for JsSignedJson
Source§type Anchor = RcRefMut<JsSignedJson>
type Anchor = RcRefMut<JsSignedJson>
RefFromWasmAbi::Anchor
Source§unsafe fn ref_mut_from_abi(
js: <JsSignedJson as RefMutFromWasmAbi>::Abi,
) -> <JsSignedJson as RefMutFromWasmAbi>::Anchor
unsafe fn ref_mut_from_abi( js: <JsSignedJson as RefMutFromWasmAbi>::Abi, ) -> <JsSignedJson as RefMutFromWasmAbi>::Anchor
RefFromWasmAbi::ref_from_abi
Source§impl TryFromJsValue for JsSignedJson
impl TryFromJsValue for JsSignedJson
Source§fn try_from_js_value(
value: JsValue,
) -> Result<JsSignedJson, <JsSignedJson as TryFromJsValue>::Error>
fn try_from_js_value( value: JsValue, ) -> Result<JsSignedJson, <JsSignedJson as TryFromJsValue>::Error>
Source§impl VectorFromWasmAbi for JsSignedJson
impl VectorFromWasmAbi for JsSignedJson
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi( js: <JsSignedJson as VectorFromWasmAbi>::Abi, ) -> Box<[JsSignedJson]>
Source§impl VectorIntoWasmAbi for JsSignedJson
impl VectorIntoWasmAbi for JsSignedJson
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi( vector: Box<[JsSignedJson]>, ) -> <JsSignedJson as VectorIntoWasmAbi>::Abi
Auto Trait Implementations§
impl Freeze for JsSignedJson
impl RefUnwindSafe for JsSignedJson
impl Send for JsSignedJson
impl Sync for JsSignedJson
impl Unpin for JsSignedJson
impl UnwindSafe for JsSignedJson
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::Abi
Source§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
.