鍵 ID • nonce : 行毎のランダム値(ナンス) 12 create table privates ( note_id bigint generated by default as identity, updated_at timestamp with time zone, secret_note text not null, key_id uuid not null default '【準備2.で出たid】'::uuid, nonce bytea default pgsodium.crypto_aead_det_noncegen(), userid uuid not null, primary key (note_id) );
alter table privates enable row level security; create policy "Users can view their own private profile." on privates for select using ( auth.uid() = userid ); create policy "Users can insert their own private profile." on privates for insert with check ( auth.uid() = userid ); create policy "Users can update their own private profile." on privates for update using ( auth.uid() = userid );
◦ 内容はオリジナル(おそらく本来のものとは違う) 15 create view decrypted_privates as select note_id, userid, decrypted_secret_note from pgsodium_masks.privates where auth.uid() = userid order by userid asc, note_id desc limit 1;
permission denied for function crypto_aead_det_decrypt のエラーが発生しないように 16 grant select on pgsodium.valid_key to authenticated; grant execute on all functions in schema pgsodium to authenticated;